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

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

 



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 <gitster@xxxxxxxxx>
---
 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

--
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]