All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/5] cleanup duplicate name_compare() functions
@ 2014-06-18 18:45 Jeremiah Mahler
  2014-06-18 18:45 ` [PATCH v3 1/5] cache: rename cache_name_compare() to name_compare() Jeremiah Mahler
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Jeremiah Mahler @ 2014-06-18 18:45 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Torsten Bögershausen, git, Jeremiah Mahler

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

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

end of thread, other threads:[~2014-06-19  8:54 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-18 18:45 [PATCH v3 0/5] cleanup duplicate name_compare() functions Jeremiah Mahler
2014-06-18 18:45 ` [PATCH v3 1/5] cache: rename cache_name_compare() to name_compare() Jeremiah Mahler
2014-06-18 19:11   ` Jonathan Nieder
2014-06-18 18:45 ` [PATCH v3 2/5] tree-walk.c: remove name_compare() function Jeremiah Mahler
2014-06-18 19:03   ` Jonathan Nieder
2014-06-19  8:04     ` Jeremiah Mahler
2014-06-18 18:45 ` [PATCH v3 3/5] unpack-trees.c: " Jeremiah Mahler
2014-06-18 19:04   ` Jonathan Nieder
2014-06-18 18:45 ` [PATCH v3 4/5] dir.c: rename to name_compare() Jeremiah Mahler
2014-06-18 19:09   ` Jonathan Nieder
2014-06-18 18:45 ` [PATCH v3 5/5] name-hash.c: " Jeremiah Mahler
2014-06-18 19:10   ` Jonathan Nieder
2014-06-18 19:14 ` [PATCH v3 0/5] cleanup duplicate name_compare() functions Jonathan Nieder
2014-06-19  8:04   ` Jeremiah Mahler
2014-06-19  8:54     ` Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.