Merge branch 'ds/for-each-file-in-obj-micro-optim'
The code to iterate over loose object files got optimized. * ds/for-each-file-in-obj-micro-optim: sha1_file: use strbuf_add() instead of strbuf_addf()
This commit is contained in:
commit
97e1f857fc
12
sha1_file.c
12
sha1_file.c
@ -1964,7 +1964,6 @@ int for_each_file_in_obj_subdir(unsigned int subdir_nr,
|
|||||||
origlen = path->len;
|
origlen = path->len;
|
||||||
strbuf_complete(path, '/');
|
strbuf_complete(path, '/');
|
||||||
strbuf_addf(path, "%02x", subdir_nr);
|
strbuf_addf(path, "%02x", subdir_nr);
|
||||||
baselen = path->len;
|
|
||||||
|
|
||||||
dir = opendir(path->buf);
|
dir = opendir(path->buf);
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
@ -1975,15 +1974,18 @@ int for_each_file_in_obj_subdir(unsigned int subdir_nr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
oid.hash[0] = subdir_nr;
|
oid.hash[0] = subdir_nr;
|
||||||
|
strbuf_addch(path, '/');
|
||||||
|
baselen = path->len;
|
||||||
|
|
||||||
while ((de = readdir(dir))) {
|
while ((de = readdir(dir))) {
|
||||||
|
size_t namelen;
|
||||||
if (is_dot_or_dotdot(de->d_name))
|
if (is_dot_or_dotdot(de->d_name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
namelen = strlen(de->d_name);
|
||||||
strbuf_setlen(path, baselen);
|
strbuf_setlen(path, baselen);
|
||||||
strbuf_addf(path, "/%s", de->d_name);
|
strbuf_add(path, de->d_name, namelen);
|
||||||
|
if (namelen == GIT_SHA1_HEXSZ - 2 &&
|
||||||
if (strlen(de->d_name) == GIT_SHA1_HEXSZ - 2 &&
|
|
||||||
!hex_to_bytes(oid.hash + 1, de->d_name,
|
!hex_to_bytes(oid.hash + 1, de->d_name,
|
||||||
GIT_SHA1_RAWSZ - 1)) {
|
GIT_SHA1_RAWSZ - 1)) {
|
||||||
if (obj_cb) {
|
if (obj_cb) {
|
||||||
@ -2002,7 +2004,7 @@ int for_each_file_in_obj_subdir(unsigned int subdir_nr,
|
|||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
||||||
strbuf_setlen(path, baselen);
|
strbuf_setlen(path, baselen - 1);
|
||||||
if (!r && subdir_cb)
|
if (!r && subdir_cb)
|
||||||
r = subdir_cb(subdir_nr, path->buf, data);
|
r = subdir_cb(subdir_nr, path->buf, data);
|
||||||
|
|
||||||
|
@ -35,4 +35,8 @@ test_perf 'git log --oneline --raw --parents' '
|
|||||||
git log --oneline --raw --parents >/dev/null
|
git log --oneline --raw --parents >/dev/null
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_perf 'git log --oneline --raw --parents -1000' '
|
||||||
|
git log --oneline --raw --parents -1000 >/dev/null
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user