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>
Nguyễn Thái Ngọc Duy committed
Aug 10, 2014 at 09:29 UTC
42de4b169c5de9d3f22eb1f988aa5b69447951b2
1 file changed
+7
-15
builtin/mv.c
+7
-15
@@ -176,22 +176,14 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
176
if (last - first < 1)
177
bad = _("source directory is empty");
178
else {
179
- int j, dst_len;
179
+ int j, dst_len, n;
180
181
- if (last - first > 0) {
182
- source = xrealloc(source,
183
- (argc + last - first)
184
- * sizeof(char *));
185
- destination = xrealloc(destination,
186
- (argc + last - first)
187
- * sizeof(char *));
188
- modes = xrealloc(modes,
189
- (argc + last - first)
190
- * sizeof(enum update_mode));
191
- submodule_gitfile = xrealloc(submodule_gitfile,
192
- (argc + last - first)
193
- * sizeof(char *));
194
- }
181
+ n = argc + last - first;
182
+ source = xrealloc(source, n * sizeof(char *));
183
+ destination = xrealloc(destination, n * sizeof(char *));
184
+ modes = xrealloc(modes, n * sizeof(enum update_mode));
185
+ submodule_gitfile =
186
+ xrealloc(submodule_gitfile, n * sizeof(char *));
187
188
dst = add_slash(dst);
189
dst_len = strlen(dst);