Fix up ugly open-coded "alloc_nr()" user in object.c
- From
Linus Torvalds <torvalds@linux-foundation.org>
- Date
- Jun 16, 2007, 17:30 UTC
- Message-ID
- <alpine.LFD.0.98.0706161024220.14121@woody.linux-foundation.org>
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;