Subject: [PATCH 04/11] object: next_size() helper for readability

From: Junio C Hamano <[email-masked]>
Date: Thu, 11 Aug 2011 10:53:09 -0700

Move the heuristics to grow the table size into a separate
helper function to make the caller more readable.

Signed-off-by: Junio C Hamano <[email-masked]>
---
 object.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/object.c b/object.c
index 4ff2d7d..259a67e 100644
--- a/object.c
+++ b/object.c
@@ -81,10 +81,15 @@ struct object *lookup_object(const unsigned char *sha1)
 	return obj;
 }
 
+static int next_size(int sz)
+{
+	return sz < 32 ? 32 : 2 * sz;
+}
+
 static void grow_object_hash(void)
 {
 	int i;
-	int new_hash_size = obj_hash_size < 32 ? 32 : 2 * obj_hash_size;
+	int new_hash_size = next_size(obj_hash_size);
 	struct object **new_hash;
 
 	new_hash = xcalloc(new_hash_size, sizeof(struct object *));
-- 
1.7.6.433.g1421f