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

[PATCH] read-cache.c: reduce unnecessary cache entry name copying

From
ZheNing Hu via GitGitGadget <gitgitgadget@gmail.com>
Date
Jun 5, 2022, 13:37 UTC
Message-ID
<pull.1249.git.1654436248249.gitgitgadget@gmail.com>
From: ZheNing Hu <adlternative@gmail.com>

In function create_from_disk, we have already copy the cache entries name from disk or previous cache entry, we can reduce unnecessary copy before that.

Signed-off-by: ZheNing Hu <adlternative@gmail.com>
---
    read-cache.c: reduce unnecessary cache entry name copying
    
    Index cache entries name are copied twice wrongly, so reduce the first
    one to fix it.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1249%2Fadlternative%2Fzh%2Frm-ce-copy-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1249/adlternative/zh/rm-ce-copy-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1249
 read-cache.c | 2 --
 1 file changed, 2 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index 96ce489c7c5..e61af3a3d4d 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1944,8 +1944,6 @@ static struct cache_entry *create_from_disk(struct mem_pool *ce_mem_pool,
 	ce->ce_namelen = len;
 	ce->index = 0;
 	oidread(&ce->oid, ondisk->data);
-	memcpy(ce->name, name, len);
-	ce->name[len] = '\0';
 
 	if (expand_name_field) {
 		if (copy_len)

base-commit: ab336e8f1c8009c8b1aab8deb592148e69217085
-- 
gitgitgadget
Next: René Scharfe
Message 1 of 3 in “read-cache.c: reduce unnecessary cache entry name copying”
  1. read-cache.c: reduce unnecessary cache entry name copyingZheNing Hu via GitGitGadget, Jun 5, 2022
  2. René ScharfeJun 6, 2022
  3. Junio C HamanoJun 6, 2022

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.