mv: remove an "if" that's always true
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sun, 10 Aug 2014 02:29:32 +0000 (09:29 +0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 3 Sep 2014 21:59:43 +0000 (14:59 -0700)
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@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/mv.c
index 5a8ff000475f6382d58d88cfd298e5436b8491f9..3b19ca26b2bb8db5ffb273b7cc40c09ae88e8908 100644 (file)
@@ -176,22 +176,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);