Fix up ugly open-coded "alloc_nr()" user in object.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxx>
---

  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;
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux