aboutsummaryrefslogtreecommitdiff
path: root/builtin/mv.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-08-10 09:29:32 +0700
committerJunio C Hamano <gitster@pobox.com>2014-09-03 14:59:43 -0700
commit42de4b169c5de9d3f22eb1f988aa5b69447951b2 (patch)
tree6d8e23e172ebec711698de49181e3ae9c0b46e89 /builtin/mv.c
parent3af05a6d0da3addbcc050f3b1a1ac379e6c4025c (diff)
downloadgit-42de4b169c5de9d3f22eb1f988aa5b69447951b2.tar.gz
git-42de4b169c5de9d3f22eb1f988aa5b69447951b2.tar.xz
mv: remove an "if" that's always true
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>
Diffstat (limited to 'builtin/mv.c')
-rw-r--r--builtin/mv.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/builtin/mv.c b/builtin/mv.c
index 5a8ff0004..3b19ca26b 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -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);