[PATCH] Make ALLOC_GROW to avoid computing alloc_nr twice.

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

 



This makes the macro also more readable.

Signed-off-by: Carlos Rica <jasampler@xxxxxxxxx>
---

   I'm not sure if this could be more efficient,
   since it replaces the computing of one more
   alloc_nr expression with one assignment more.
   It is much easier to read this way, I think.

 cache.h |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/cache.h b/cache.h
index 493983c..3e0842f 100644
--- a/cache.h
+++ b/cache.h
@@ -240,10 +240,9 @@ extern void verify_non_filename(const char *prefix, const char *name);
 #define ALLOC_GROW(x, nr, alloc) \
 	do { \
 		if ((nr) > alloc) { \
-			if (alloc_nr(alloc) < (nr)) \
+			alloc = alloc_nr(alloc); \
+			if (alloc < (nr)) \
 				alloc = (nr); \
-			else \
-				alloc = alloc_nr(alloc); \
 			x = xrealloc((x), alloc * sizeof(*(x))); \
 		} \
 	} while(0)
-- 
1.5.0

-
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