From: Junio C Hamano Date: Sat, 23 Aug 2008 09:03:07 GMT Subject: Re: [PATCH 1/5] Allow alternate "low-level" emit function from xdl_diff Message-ID: <7vy72o14tw.fsf@gitster.siamese.dyndns.org> In-Reply-To: <48AFC73F.2010100@lsrfire.ath.cx> René Scharfe writes: > Could we move more code into the library code to avoid that ugliness? > > AFAICS, compare_buffer() builds a struct patch with an array of > struct chunks, whose members are then fed one by one into either > blame_chunk() or handle_split(). Could we avoid the allocation > altogether by using a different interface? > > E.g. have a callback like this: > > static void handle_split_cb(long same, long p_next, long t_next, > void *data) > { > struct chunk_cb_data *d = data; > handle_split(d->sb, d->ent, d->tlno, d->plno, same, > d->parent, d->split); > d->plno = p_next; > d->tlno = t_next; > } > > And use it like this: > > struct chunk_cb_data d = {sb, ent, 0, 0, parent, split}; > xpparam_t xpp; > xdemitconf_t xecfg; > > xpp.flags = xdl_opts; > memset(&xecfg, 0, sizeof(xecfg)); > xecfg.ctxlen = context; > xdi_diff_chunks(file_p, file_o, &xpp, &xecfg, handle_split_cb, &d); > handle_split(sb, ent, d.tlno, d.plno, ent->num_lines, > parent, split); > > Makes sense? Absolutely; very well formulated. Thanks.