Skip to content

Commit 250d6c7

Browse files
committed
Tiny optimization
Don't check for aliases if we know it's the flag's name already
1 parent f8b65f4 commit 250d6c7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

flag.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,11 @@ bool flag_parse(int argc, char **argv)
233233
for (size_t i = 0; i < c->flags_count; ++i) {
234234
bool is_name = strcmp(c->flags[i].name, flag) == 0;
235235
bool is_alias = false;
236-
for (size_t j = 0; !is_alias && j < c->flags[i].alias_count; ++j) {
237-
if (strcmp(c->flags[i].aliases[j], flag) == 0)
238-
is_alias = true;
236+
if (!is_name) {
237+
for (size_t j = 0; !is_alias && j < c->flags[i].alias_count; ++j) {
238+
if (strcmp(c->flags[i].aliases[j], flag) == 0)
239+
is_alias = true;
240+
}
239241
}
240242
if (is_name || is_alias) {
241243
static_assert(COUNT_FLAG_TYPES == 4, "Exhaustive flag type parsing");

0 commit comments

Comments
 (0)