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

[PATCH v5 1/2] name-hash.c: replace cache_name_compare() with memcmp()

From
Jeremiah Mahler <jmmahler@gmail.com>
Date
Jun 20, 2014, 02:06 UTC
Message-ID
<1403230004-11034-2-git-send-email-jmmahler@gmail.com>
In-Reply-To
<1403230004-11034-1-git-send-email-jmmahler@gmail.com>

When cache_name_compare() is used on counted strings of the same length, it is equivalent to a memcmp(). Since the one use of cache_name_compare() in name-hash.c requires that the lengths are equal, just replace it with memcmp().

Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com>
---
 name-hash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/name-hash.c b/name-hash.c
index be7c4ae..63cc188 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -179,7 +179,7 @@ static int same_name(const struct cache_entry *ce, const char *name, int namelen
 	 * Always do exact compare, even if we want a case-ignoring comparison;
 	 * we do the quick exact one first, because it will be the common case.
 	 */
-	if (len == namelen && !cache_name_compare(name, namelen, ce->name, len))
+	if (len == namelen && !memcmp(name, ce->name, len))
 		return 1;
 
 	if (!icase)
-- 
2.0.0.694.g5736dad
Previous: Jeremiah MahlerNext: Junio C Hamano
Message 2 of 5 in “cleanup duplicate name_compare() functions”
  1. 0/2 cleanup duplicate name_compare() functionsJeremiah Mahler, Jun 20, 2014
  2. 1/2 name-hash.c: replace cache_name_compare() with memcmp()Jeremiah Mahler, Jun 20, 2014
  3. Junio C HamanoJun 20, 2014
  4. 2/2 cleanup duplicate name_compare() functionsJeremiah Mahler, Jun 20, 2014
  5. Junio C HamanoJun 20, 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.