@matheusbsbs / matheus-bagliano / commits / de551d472e
Fork 0

process_{tree,blob}: Remove useless xstrdup calls

The name of the processed object was duplicated for passing it to add_object(), but that already calls path_name, which allocates a new string anyway. So the memory allocated by the xstrdup calls just went nowhere, leaking memory. This reduces the RSS usage for a "rev-list --all --objects" by about 10% on the gentoo repo (fully packed) as well as linux-2.6.git: gentoo: | old | new ----------------|------------------------------- RSS | 1537284 | 1388408 VSZ | 1816852 | 1667952 time elapsed | 1:49.62 | 1:48.99 min. page faults| 417178 | 379919 linux-2.6.git: | old | new ----------------|------------------------------- RSS | 324452 | 292996 VSZ | 491792 | 460376 time elapsed | 0:14.53 | 0:14.28 min. page faults| 89360 | 81613 Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Björn Steinbrink committed Apr 8, 2009 at 13:28 UTC de551d472ed65fa570d9456e8498348fe4c8e7d8
2 files changed -3
list-objects.c
-2
@@ -23,7 +23,6 @@ static void process_blob(struct rev_info *revs,
23 if (obj->flags & (UNINTERESTING | SEEN))
24 return;
25 obj->flags |= SEEN;
26 - name = xstrdup(name);
26 add_object(obj, p, path, name);
27 }
28
@@ -78,7 +77,6 @@ static void process_tree(struct rev_info *revs,
77 if (parse_tree(tree) < 0)
78 die("bad tree object %s", sha1_to_hex(obj->sha1));
79 obj->flags |= SEEN;
81 - name = xstrdup(name);
80 add_object(obj, p, path, name);
81 me.up = path;
82 me.elem = name;
reachable.c
-1
@@ -48,7 +48,6 @@ static void process_tree(struct tree *tree,
48 obj->flags |= SEEN;
49 if (parse_tree(tree) < 0)
50 die("bad tree object %s", sha1_to_hex(obj->sha1));
51 - name = xstrdup(name);
51 add_object(obj, p, path, name);
52 me.up = path;
53 me.elem = name;