git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH] generalizing sorted-array handling

From
Yann Dirson <ydirson@altern.org>
Date
Nov 4, 2010, 20:33 UTC
Message-ID
<1288902795-8597-1-git-send-email-ydirson@altern.org>

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 ?

Next: Yann Dirson
Message 1 of 8 in “generalizing sorted-array handling”
  1. generalizing sorted-array handlingYann Dirson, Nov 4, 2010
  2. 1/4 Start to replace locate_rename_dst() with a generic function.Yann Dirson, Nov 4, 2010
  3. Jonathan NiederNov 4, 2010
  4. Yann DirsonNov 4, 2010
  5. 2/4 Abstract _locate_element() some more with elem_size parameter.Yann Dirson, Nov 4, 2010
  6. 3/4 Introduce "abstract class" to make _locate_element() more independant of diff_rename_dst.Yann Dirson, Nov 4, 2010
  7. Jonathan NiederNov 4, 2010
  8. 4/4 Remove remaining rename_dst references in _locate_element() and pass a pointer to it.Yann Dirson, Nov 4, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.