[PATCH 5/8] mv: remove an "if" that's always true

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

 



This is inside an "else" block of "if (last - first < 1)", so we know
that "last - first >= 1" when we come here. No need to check
"last - first > 0".

While at there, save "argc + last - first" to a variable to shorten
the statements a bit.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 builtin/mv.c | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/builtin/mv.c b/builtin/mv.c
index e192f2d..a45226e 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -179,22 +179,14 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 				if (last - first < 1)
 					bad = _("source directory is empty");
 				else {
-					int j, dst_len;
+					int j, dst_len, n;
 
-					if (last - first > 0) {
-						source = xrealloc(source,
-								(argc + last - first)
-								* sizeof(char *));
-						destination = xrealloc(destination,
-								(argc + last - first)
-								* sizeof(char *));
-						modes = xrealloc(modes,
-								(argc + last - first)
-								* sizeof(enum update_mode));
-						submodule_gitfile = xrealloc(submodule_gitfile,
-								(argc + last - first)
-								* sizeof(char *));
-					}
+					n = argc + last - first;
+					source = xrealloc(source, n * sizeof(char *));
+					destination = xrealloc(destination, n * sizeof(char *));
+					modes = xrealloc(modes, n * sizeof(enum update_mode));
+					submodule_gitfile =
+						xrealloc(submodule_gitfile, n * sizeof(char *));
 
 					dst = add_slash(dst);
 					dst_len = strlen(dst);
-- 
2.1.0.rc0.78.gc0d8480

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