summaryrefslogtreecommitdiff
path: root/builtin/pack-refs.c
diff options
context:
space:
mode:
authorLibravatar Nguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-12-28 06:39:48 +0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-12-29 12:40:48 -0800
commit06a604e67051b9342c158432a49e42a5440f9280 (patch)
tree3e12aec4d1febf9d679865949fea89471acc25e0 /builtin/pack-refs.c
parentattr: do not attempt to expand when we know it's not a macro (diff)
downloadtgif-06a604e67051b9342c158432a49e42a5440f9280.tar.xz
attr: avoid heavy work when we know the specified attr is not defined
If we have never seen attr 'X' in any .gitattributes file we have examined so far, we can be sure that 'X' is not defined. So no need to go over all the attr stack to look for attr 'X'. This is the purpose behind this new field maybe_real. This optimization breaks down if macros are involved because we can't know for sure what macro would expand to 'X' at attr parsing time. But if we go the pessimistic way and assume all macros are expanded, we hit the builtin "binary" macro. At least the "diff" attr defined in this macro will disable this optimization for git-grep. So we wait until any attr lines _may_ reference to a macro before we turn this off. In git.git, this reduces the number of fill_one() call for "git grep abcdefghi" from ~5348 to 2955. The optimization stops when it reads t/.gitattributes, which uses 'binary' macro. We could probably reduce it further by limiting the 'binary' reference to t/ and subdirs only in this case. "git grep" is actually a good example to justify this patch. The command checks "diff" attribute on every file. People usually don't define this attribute. But they pay the attr lookup penalty anyway without this patch, proportional to the number of attr lines they have in repo. Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/pack-refs.c')
0 files changed, 0 insertions, 0 deletions