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

[PATCH v3 0/5] cleanup duplicate name_compare() functions

From
Jeremiah Mahler <jmmahler@gmail.com>
Date
Jun 18, 2014, 18:45 UTC
Message-ID
<1403117117-10384-1-git-send-email-jmmahler@gmail.com>

Version 3 of the patch series to cleanup duplicate name_compare() functions (previously was 'add strnncmp() function' [1]).

This version goes in a slightly different direction than the previous version. Before I was trying to add a strnncmp() function so I could remove duplicate copies of the name_compare() function in tree-walk.c and unpack-trees.c. But then Torsten Bögershausen pointed out that there is a cache_name_compare() function which is nearly identical to name_compare() [2]*.

* cache_name_compare() is not identical to name_compare().  The former
  returns +1, -1, whereas the latter returns +N, -N.  But there is no
  place where name_compare() was used that needed the magnitude so this
  change would not alter its behavior.

So I decided why not generalize the name of cache_name_compare() by renaming it to name_compare(), since it doesn't do anything with caches, other than being part of cache.h and read-cache.c. Then the duplicate name_compare() functions can be removed and the few places that used cache_name_compare() can be renamed to name_compare().

It cleans up the code with a minimal number of changes. It keeps existing functions instead of creating new ones. And there are several other functions in cache.h that are similarly named '*name_compare' so it follows the already established style.

Also, the name_compare() now uses memcmp() as it did originally instead of using strncmp() as it did in the last version.

[1]: http://marc.info/?l=git&m=140299051431479&w=2
[2]: http://marc.info/?l=git&m=140300329403706&w=2
Jeremiah Mahler (5):
  cache: rename cache_name_compare() to name_compare()
  tree-walk.c: remove name_compare() function
  unpack-trees.c: remove name_compare() function
  dir.c: rename to name_compare()
  name-hash.c: rename to name_compare()
 cache.h        |  2 +-
 dir.c          |  3 +--
 name-hash.c    |  2 +-
 read-cache.c   | 23 +++++++++++++----------
 tree-walk.c    | 10 ----------
 unpack-trees.c | 11 -----------
 6 files changed, 16 insertions(+), 35 deletions(-)
-- 
2.0.0
Next: Jeremiah Mahler
Message 1 of 15 in “cleanup duplicate name_compare() functions”
  1. 0/5 cleanup duplicate name_compare() functionsJeremiah Mahler, Jun 18, 2014
  2. 1/5 cache: rename cache_name_compare() to name_compare()Jeremiah Mahler, Jun 18, 2014
  3. Jonathan NiederJun 18, 2014
  4. 2/5 tree-walk.c: remove name_compare() functionJeremiah Mahler, Jun 18, 2014
  5. Jonathan NiederJun 18, 2014
  6. Jeremiah MahlerJun 19, 2014
  7. 3/5 unpack-trees.c: remove name_compare() functionJeremiah Mahler, Jun 18, 2014
  8. Jonathan NiederJun 18, 2014
  9. 4/5 dir.c: rename to name_compare()Jeremiah Mahler, Jun 18, 2014
  10. Jonathan NiederJun 18, 2014
  11. 5/5 name-hash.c: rename to name_compare()Jeremiah Mahler, Jun 18, 2014
  12. Jonathan NiederJun 18, 2014
  13. Jonathan NiederJun 18, 2014
  14. Jeremiah MahlerJun 19, 2014
  15. Jeff KingJun 19, 2014

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.