I merged your changes into hg tip.

Thanks for your work!

Regards,
Anselm

On Thu, Jun 08, 2006 at 01:02:38AM -0400, Kris Maglione wrote:
> For those of you who don't frequent #wmii, uriel and I have been grumbling 
> about the use of cext_vectors everywhere in wmii. They've become somewhat 
> of a ubiquitous, generic list hack. A few days ago, I rewrote all of the 
> code that uses vectors in wmii and libixp (except for wmiimenu, which I 
> missed) and replaced them with linked lists.  As well, everything that 
> previously used an index now uses a pointer, including sel, c->sel, 
> a->sel..., several create_* functions, and the i1, i2 and i3 vars in fs.c. 
> There are a few other uses of indexes and lengths that need to be cleaned 
> up or removed. From my testing and uriel's, the code seems stable.
> 
> The main benefit of this change is cleaner, more readable code in almost 
> all circumstances (although there is still some tidying up to do in some 
> areas), and in most circumstances, more efficient code (for instance, fewer 
> unnecessary memcpys or mallocs). The side benefit is that I've saved ~10 
> lines of code at last count, not including those no longer necessary in 
> vector.c (all 41 of them).
> 
> The lists are usually just a 'Type *next;' member in the begining of a 
> struct, but frames have separate links for clients and areas, and keys, as 
> a special case, have three links (though they're no more confusing, and 
> certainly not more memory intensive, than before).
> 
> My repo is public, and the address is available in /home/bsdaemon/repo on 
> wmii.de, in order to keep from pissing my cable company off too much. 
> Anyone without access to wmii.de can email me privately for the address. 
> Hopefully, the changes will be merged and that won't be necessary, though.
> 
> The repository also has a few other changes which I can live with or 
> without.  I've added cext_assert, which I've used in only a few places, but 
> which I hope will be incorperated into more of wmii's code. I've added a 
> va_args version of stat_of_name which saves 30SLOC, although I'd like to 
> see fs.c rewritten not to need it ;). I've replaced unpack_* qid functions 
> with a struct PackedQid which is unioned with Qid, although I'd be just as 
> happy to see them replaced with macros.
> 
> Here are some uglier examples:
> -     unsigned int i;
> -     for(i = 0; i < client.size; i++) {
> -             Client *c = client.data[i];
> -             if(c->frame.size && c->frame.data[c->sel]->area) {
> -                     if(idx_of_area(c->frame.data[c->sel]->area))
> -                             resize_column(c, 
> &c->frame.data[c->sel]->rect, nil);
> +     Client *c;
> +     for(c = client; c; c=c->next) {
> +             if(c->frame && c->sel->area) {
> +                     if(idx_of_area(c->sel->area))
> +                             resize_column(c, &c->sel->rect, nil);
> (here, though, index of area will be replaced. Probably with this macro:
> #define is_floating(a) ((a) == ((a)->view->area))
> )
> ---
> -     unsigned int i;
> -     for(i = 0; i < client.size; i++) {
> -             Client *c = client.data[i];
> -             if(c->frame.size && (c->frame.data[c->sel]->area->view == 
> view.data[sel]))
> +     Client *c;
> +     for(c=client; c; c=c->next)
> +             if(c->sel && (c->sel->area->view == sel))
> ---
> -     for(i = 1; (i < v->area.size) &&
> -                     !blitz_ispointinrect(pt->x, pt->y, 
> &v->area.data[i]->rect); i++);
> -     if(i < v->area.size) {
> -             Area *a = v->area.data[i];
> -             for(j = 0; j < a->frame.size &&
> -                             !blitz_ispointinrect(pt->x, pt->y, 
> &a->frame.data[j]->rect); j++);
> -             if(j < a->frame.size)
> -                     f = a->frame.data[j];
> +     for(a=v->area->next; a; a=a->next)
> +                     !blitz_ispointinrect(pt->x, pt->y, &a->rect);
> +     if(a) {
> +             for(f=a->frame; f && !blitz_ispointinrect(pt->x, pt->y, 
> &f->rect);
> +                     f=f->anext);
> (yes, this is semantically correct)
> ---
> -                     f = view.data[i1]->area.data[i2]->frame.data[i3];
> -                     snprintf(buf, sizeof(buf), "%d", 
> idx_of_client_id(f->client->id));
> +                     f = FRAME(i3);
> +                     snprintf(buf, sizeof(buf), "%d", 
> idx_of_client(f->client));
> (here, FRAME(f) is defined as ((Frame *)(f))  )
> ---
> -                             if((fcall->count = 
> strlen(view.data[i1]->area.data[i2]->frame.data[i3]->client->props)))
> -                                     memcpy(p, 
> view.data[i1]->area.data[i2]->frame.data[i3]->client->props, fcall->count);
> +                             if((fcall->count = 
> strlen(FRAME(i3)->client->props)))
> +                                     memcpy(p, FRAME(i3)->client->props, 
> fcall->count);
> 
> 
> -- 
> Kris Maglione
> 
> The more elaborate and costly the equipment, the greater
> the chance of having to stop at the fish market
> on the way home.
> 
> _______________________________________________
> [email protected] mailing list
> http://wmii.de/cgi-bin/mailman/listinfo/wmii

-- 
 Anselm R. Garbe  ><><  www.ebrag.de  ><><  GPG key: 0D73F361

_______________________________________________
[email protected] mailing list
http://wmii.de/cgi-bin/mailman/listinfo/wmii

Reply via email to