aboutsummaryrefslogtreecommitdiffstats
path: root/parse-options.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2024-03-03 13:19:39 +0100
committerJunio C Hamano <gitster@pobox.com>2024-03-03 09:49:21 -0800
commit597f9d037df56334b9dc938ffcfeb9a879f80a7c (patch)
tree87b7701ba73fc322ab4af0f70e0caa913dc72dfe /parse-options.c
parent289cb15541874e5c1599fee2e145a7af39085069 (diff)
downloadgit-597f9d037df56334b9dc938ffcfeb9a879f80a7c.tar.gz
parse-options: set arg of abbreviated option lazily
Postpone setting the opt pointer until we're about to call get_value(), which uses it. There's no point in setting it eagerly for every abbreviated candidate option, which may turn out to be ambiguous. Removing this assignment from the loop doesn't noticeably improve the performance, but allows further simplification. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/parse-options.c b/parse-options.c
index e4ce33ea48..056c6b30e9 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -391,8 +391,6 @@ is_abbreviated:
ambiguous_option = abbrev_option;
ambiguous_flags = abbrev_flags;
}
- if (*arg_end)
- p->opt = arg_end + 1;
abbrev_option = options;
abbrev_flags = flags ^ opt_flags;
continue;
@@ -441,8 +439,11 @@ is_abbreviated:
abbrev_option->long_name);
return PARSE_OPT_HELP;
}
- if (abbrev_option)
+ if (abbrev_option) {
+ if (*arg_end)
+ p->opt = arg_end + 1;
return get_value(p, abbrev_option, abbrev_flags);
+ }
return PARSE_OPT_UNKNOWN;
}