From de551d472ed65fa570d9456e8498348fe4c8e7d8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B6rn=20Steinbrink?= Date: Wed, 8 Apr 2009 13:28:54 +0200 Subject: [PATCH] process_{tree,blob}: Remove useless xstrdup calls MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- list-objects.c | 2 -- reachable.c | 1 - 2 files changed, 3 deletions(-) diff --git a/list-objects.c b/list-objects.c index c8b8375e49..dd243c7c66 100644 --- a/list-objects.c +++ b/list-objects.c @@ -23,7 +23,6 @@ static void process_blob(struct rev_info *revs, if (obj->flags & (UNINTERESTING | SEEN)) return; obj->flags |= SEEN; - name = xstrdup(name); add_object(obj, p, path, name); } @@ -78,7 +77,6 @@ static void process_tree(struct rev_info *revs, if (parse_tree(tree) < 0) die("bad tree object %s", sha1_to_hex(obj->sha1)); obj->flags |= SEEN; - name = xstrdup(name); add_object(obj, p, path, name); me.up = path; me.elem = name; diff --git a/reachable.c b/reachable.c index 3b1c18ff9b..b515fa2de3 100644 --- a/reachable.c +++ b/reachable.c @@ -48,7 +48,6 @@ static void process_tree(struct tree *tree, obj->flags |= SEEN; if (parse_tree(tree) < 0) die("bad tree object %s", sha1_to_hex(obj->sha1)); - name = xstrdup(name); add_object(obj, p, path, name); me.up = path; me.elem = name; -- 2.11.4.GIT