Git development
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Junio C Hamano <junkio@cox.net>, Git Mailing List <git@vger.kernel.org>
Subject: Fix up ugly open-coded "alloc_nr()" user in object.c
Date: Sat, 16 Jun 2007 10:30:22 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.0.98.0706161024220.14121@woody.linux-foundation.org> (raw)


When adding objects to the object/mode array, we used to have our own 
alloc_nr() implementation, rather than use the normal one.

And since the normal one is arguably a bit nicer (still grows the 
allocation exponentially, just not by more-than-doubling it every time), 
why not just use it?

That array of objects ends up being really quite big when you force a 
while repack of a big project, and while we might end up doing a few more 
xreallocs in the process, we also hopefully don't end up with a final 
allocation that is quite as wastefully big.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---

  That was an overkill of a situation for a trivial patch that I don't 
  think is in the least interesting or even important. I really don't care 
  if you take this, Junio, but it seemed the obvious one-liner to do, so 
  I'm sending it in anyway.

 object.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/object.c b/object.c
index 16793d9..fdd6ceb 100644
--- a/object.c
+++ b/object.c
@@ -245,7 +245,7 @@ void add_object_array_with_mode(struct object *obj, const char *name, struct obj
 	struct object_array_entry *objects = array->objects;
 
 	if (nr >= alloc) {
-		alloc = (alloc + 32) * 2;
+		alloc = alloc_nr(alloc);
 		objects = xrealloc(objects, alloc * sizeof(*objects));
 		array->alloc = alloc;
 		array->objects = objects;

             reply	other threads:[~2007-06-16 17:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-16 17:30 Linus Torvalds [this message]
2007-06-16 18:21 ` Fix up ugly open-coded "alloc_nr()" user in object.c Jeff King
2007-06-16 22:15   ` Olivier Galibert
2007-06-16 22:37     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.0.98.0706161024220.14121@woody.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox