diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-12-15 22:02:42 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-02-03 14:08:16 -0800 |
commit | 48932677d62e426b3f26ac236384cb5195fb9dfd (patch) | |
tree | d58115641e35cc305af9b5f48e6fcf39f5cfee35 /tree-walk.h | |
parent | 3bd2bcfa982c69c0f5722c3dfe72b15cd0469d15 (diff) | |
download | git-48932677d62e426b3f26ac236384cb5195fb9dfd.tar.gz |
diff-tree: convert base+baselen to writable strbuf
In traversing trees, a full path is splitted into two parts: base
directory and entry. They are however quite often concatenated
whenever a full path is needed. Current code allocates a new buffer,
do two memcpy(), use it, then release.
Instead this patch turns "base" to a writable, extendable buffer. When
a concatenation is needed, the callee only needs to append "entry" to
base, use it, then truncate the entry out again. "base" must remain
unchanged before and after entering a function.
This avoids quite a bit of malloc() and memcpy().
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 'tree-walk.h')
-rw-r--r-- | tree-walk.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tree-walk.h b/tree-walk.h index c12f0a2978..f81c232b5a 100644 --- a/tree-walk.h +++ b/tree-walk.h @@ -60,6 +60,6 @@ static inline int traverse_path_len(const struct traverse_info *info, const stru return info->pathlen + tree_entry_len(n->path, n->sha1); } -extern int tree_entry_interesting(const struct name_entry *, const char *, int, const struct pathspec *ps); +extern int tree_entry_interesting(const struct name_entry *, const struct strbuf *, const struct pathspec *ps); #endif |