[PATCH 5/7] ls-files: refactor read_one_entry_quick() to use a strbuf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Refactor the code in read_one_entry_quick() that used "base" and
"baselen" to just use the "buf" and "len" fields in the "base" strbuf
directly. Having the "basebuf" variable was a transitory step in
moving away from the old read_tree() in tree.c.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
---
 builtin/ls-files.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index f5239437809..c0349a7b206 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -421,14 +421,12 @@ static int get_common_prefix_len(const char *common_prefix)
 }
 
 static int read_one_entry_quick(const struct object_id *oid,
-				struct strbuf *basebuf,
+				struct strbuf *base,
 				const char *pathname,
 				unsigned mode,
 				int stage, void *context)
 {
 	struct index_state *istate = context;
-	const char *base = basebuf->buf;
-	const int baselen = basebuf->len;
 	int len;
 	struct cache_entry *ce;
 
@@ -436,13 +434,13 @@ static int read_one_entry_quick(const struct object_id *oid,
 		return READ_TREE_RECURSIVE;
 
 	len = strlen(pathname);
-	ce = make_empty_cache_entry(istate, baselen + len);
+	ce = make_empty_cache_entry(istate, base->len + len);
 
 	ce->ce_mode = create_ce_mode(mode);
 	ce->ce_flags = create_ce_flags(stage);
-	ce->ce_namelen = baselen + len;
-	memcpy(ce->name, base, baselen);
-	memcpy(ce->name + baselen, pathname, len+1);
+	ce->ce_namelen = base->len + len;
+	memcpy(ce->name, base->buf, base->len);
+	memcpy(ce->name + base->len, pathname, len+1);
 	oidcpy(&ce->oid, oid);
 	return add_index_entry(istate, ce, ADD_CACHE_JUST_APPEND);
 }
-- 
2.31.0.rc0.126.g04f22c5b82




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux