Re: [dwm] idxoftag and tag names

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Sun, 11 Nov 2007 17:26:38 +0100

On Sun, Nov 11, 2007 at 07:39:54PM +0330, Ali Gholami Rudi wrote:
> idxoftag("x") fails if x is a tag name; it compares the pointers and
> not the strs.
>
> -- Ali

> diff --git a/dwm.c b/dwm.c
> --- a/dwm.c
> +++ b/dwm.c
> @@ -863,7 +863,7 @@ idxoftag(const char *tag) {
> idxoftag(const char *tag) {
> unsigned int i;
>
> - for(i = 0; (i < LENGTH(tags)) && (tags[i] != tag); i++);
> + for(i = 0; (i < LENGTH(tags)) && cmp(tags[i], tag); i++);
> return (i < LENGTH(tags)) ? i : 0;
> }

Actually it is intended that idxoftag() makes a pointer
comparision, because it assumes that always the specific
tags-array entry is used. I see no reason why one should do a
string comparision which is more expensive and would lead to at
least an additional waste of memory through allocating some
extra space for "x" instead of re-using tags[3] for instance.

Regards,

-- 
 Anselm R. Garbe >< http://www.suckless.org/ >< GPG key: 0D73F361
Received on Sun Nov 11 2007 - 17:26:38 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:05:51 UTC