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>
This commit is contained in:
parent
3af05a6d0d
commit
42de4b169c
22
builtin/mv.c
22
builtin/mv.c
@ -176,22 +176,14 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
|
|||||||
if (last - first < 1)
|
if (last - first < 1)
|
||||||
bad = _("source directory is empty");
|
bad = _("source directory is empty");
|
||||||
else {
|
else {
|
||||||
int j, dst_len;
|
int j, dst_len, n;
|
||||||
|
|
||||||
if (last - first > 0) {
|
n = argc + last - first;
|
||||||
source = xrealloc(source,
|
source = xrealloc(source, n * sizeof(char *));
|
||||||
(argc + last - first)
|
destination = xrealloc(destination, n * sizeof(char *));
|
||||||
* sizeof(char *));
|
modes = xrealloc(modes, n * sizeof(enum update_mode));
|
||||||
destination = xrealloc(destination,
|
submodule_gitfile =
|
||||||
(argc + last - first)
|
xrealloc(submodule_gitfile, n * sizeof(char *));
|
||||||
* sizeof(char *));
|
|
||||||
modes = xrealloc(modes,
|
|
||||||
(argc + last - first)
|
|
||||||
* sizeof(enum update_mode));
|
|
||||||
submodule_gitfile = xrealloc(submodule_gitfile,
|
|
||||||
(argc + last - first)
|
|
||||||
* sizeof(char *));
|
|
||||||
}
|
|
||||||
|
|
||||||
dst = add_slash(dst);
|
dst = add_slash(dst);
|
||||||
dst_len = strlen(dst);
|
dst_len = strlen(dst);
|
||||||
|
Loading…
Reference in New Issue
Block a user