git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeremiah Mahler <jmmahler@gmail.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: "Torsten Bögershausen" <tboegi@web.de>,
	git@vger.kernel.org, "Jeremiah Mahler" <jmmahler@gmail.com>
Subject: [PATCH v3 0/5] cleanup duplicate name_compare() functions
Date: Wed, 18 Jun 2014 11:45:12 -0700	[thread overview]
Message-ID: <1403117117-10384-1-git-send-email-jmmahler@gmail.com> (raw)

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

             reply	other threads:[~2014-06-18 18:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-18 18:45 Jeremiah Mahler [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1403117117-10384-1-git-send-email-jmmahler@gmail.com \
    --to=jmmahler@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    --cc=tboegi@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).