On Fri, 28 Jul 2006, Johannes Schindelin wrote: > > +/* a and b may not overlap! */ > +static void memswap(void *a, void *b, unsigned int len) This is disgusting. Especially since it's also slow as hell. > + memswap(p->new_name, p->old_name, sizeof(char *)); > + memswap(&p->new_mode, &p->old_mode, sizeof(unsigned int)); > + memswap(&p->is_new, &p->is_delete, sizeof(int)); > + memswap(&p->lines_added, &p->lines_deleted, sizeof(int)); > + memswap(p->old_sha1_prefix, p->new_sha1_prefix, 41); > + > + for (; frag; frag = frag->next) { > + memswap(&frag->newpos, &frag->oldpos, sizeof(int)); > + memswap(&frag->newlines, &frag->oldlines, sizeof(int)); All but one of those are register sizes, so doing a horribly ugly "memswap()"to do them is truly nasty, when you could have done #define swap(a,b) myswap((a),(b),sizeof(a)) #define myswap(a,b,size) do { \ unsigned char mytmp[size]; \ memcpy(tmp, &a, size); \ memcpy(&a, &b, size); \ memcpy(&b, mytmp, size); \ } while (0) and it would have worked MUCH more efficiently, since any sane compiler would immediately have noticed that you're doing word-sized copies, and optimized the hell out of it. (Untested, of course). Linus - : send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html