git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] generalizing sorted-array handling
@ 2010-11-04 20:33 Yann Dirson
  2010-11-04 20:33 ` [PATCH 1/4] Start to replace locate_rename_dst() with a generic function Yann Dirson
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Yann Dirson @ 2010-11-04 20:33 UTC (permalink / raw)
  To: git

While writing the bulk-move series, I introduced 2 new functions,
locate_bulkmove_candidate() and locate_rename_dst_dir(), closely
derived from locate_rename_dst().  That was because it seemed not so
trivial to overcome the differences in those 3 funcs while retaining
readability.

Now when working on bulk-rm (as a new basis for next-gen bulk-move), I
find myself in the need of adding more of them: again functions for
searching/inserting in a sorted list of various contents.  My first
approach (this series) was to generalize locate_rename_dst() to
operate on other "lists of a filespec and something", since that was
matching my needs for "bulkrm_candidates".

Tell me your opinion on this: I find the result hard to read, and
difficult to adapt to all of locate_rename_dst_dir() with its
non-filespec input, let alone locate_bulkmove_candidate() with 2 of
them.  And even the memset() call is probably less efficient than the
original "= NULL".

So I'm planning of redoing the thing with a different principle:
change the core function to accept func-pointer for comparison and
initialization - that would make the core func much more readable.
Since those trivial funcs would be trivial static ones, compilers
ought to be able to instantiate specific versions of the core func,
inlining those trivial ones; if it does not, however, that would
surely give a performance penalty if it does not...

The alternative, having several mostly-identical funcs, which have to
be made generic anyway to prevent proliferation, seems to me much more
of a hell.  What's the general opinion ?

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-11-04 21:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-04 20:33 [RFC PATCH] generalizing sorted-array handling Yann Dirson
2010-11-04 20:33 ` [PATCH 1/4] Start to replace locate_rename_dst() with a generic function Yann Dirson
2010-11-04 20:45   ` Jonathan Nieder
2010-11-04 21:22     ` Yann Dirson
2010-11-04 20:33 ` [PATCH 2/4] Abstract _locate_element() some more with elem_size parameter Yann Dirson
2010-11-04 20:33 ` [PATCH 3/4] Introduce "abstract class" to make _locate_element() more independant of diff_rename_dst Yann Dirson
2010-11-04 20:56   ` Jonathan Nieder
2010-11-04 20:33 ` [PATCH 4/4] Remove remaining rename_dst references in _locate_element() and pass a pointer to it Yann Dirson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).