mirror of
https://git.zx2c4.com/cgit
synced 2024-11-26 02:18:42 +00:00
cgit.c: Use "else" for mutually exclusive branches
When parsing command line arguments, no pair of command line options can ever match simultaneously. Use "else if" blocks to reflect this. This change improves both readability and speed. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
This commit is contained in:
parent
e711679618
commit
441e748564
27
cgit.c
27
cgit.c
@ -865,34 +865,25 @@ static void cgit_parse_args(int argc, const char **argv)
|
|||||||
for (i = 1; i < argc; i++) {
|
for (i = 1; i < argc; i++) {
|
||||||
if (!prefixcmp(argv[i], "--cache=")) {
|
if (!prefixcmp(argv[i], "--cache=")) {
|
||||||
ctx.cfg.cache_root = xstrdup(argv[i] + 8);
|
ctx.cfg.cache_root = xstrdup(argv[i] + 8);
|
||||||
}
|
} else if (!strcmp(argv[i], "--nocache")) {
|
||||||
if (!strcmp(argv[i], "--nocache")) {
|
|
||||||
ctx.cfg.nocache = 1;
|
ctx.cfg.nocache = 1;
|
||||||
}
|
} else if (!strcmp(argv[i], "--nohttp")) {
|
||||||
if (!strcmp(argv[i], "--nohttp")) {
|
|
||||||
ctx.env.no_http = "1";
|
ctx.env.no_http = "1";
|
||||||
}
|
} else if (!prefixcmp(argv[i], "--query=")) {
|
||||||
if (!prefixcmp(argv[i], "--query=")) {
|
|
||||||
ctx.qry.raw = xstrdup(argv[i] + 8);
|
ctx.qry.raw = xstrdup(argv[i] + 8);
|
||||||
}
|
} else if (!prefixcmp(argv[i], "--repo=")) {
|
||||||
if (!prefixcmp(argv[i], "--repo=")) {
|
|
||||||
ctx.qry.repo = xstrdup(argv[i] + 7);
|
ctx.qry.repo = xstrdup(argv[i] + 7);
|
||||||
}
|
} else if (!prefixcmp(argv[i], "--page=")) {
|
||||||
if (!prefixcmp(argv[i], "--page=")) {
|
|
||||||
ctx.qry.page = xstrdup(argv[i] + 7);
|
ctx.qry.page = xstrdup(argv[i] + 7);
|
||||||
}
|
} else if (!prefixcmp(argv[i], "--head=")) {
|
||||||
if (!prefixcmp(argv[i], "--head=")) {
|
|
||||||
ctx.qry.head = xstrdup(argv[i] + 7);
|
ctx.qry.head = xstrdup(argv[i] + 7);
|
||||||
ctx.qry.has_symref = 1;
|
ctx.qry.has_symref = 1;
|
||||||
}
|
} else if (!prefixcmp(argv[i], "--sha1=")) {
|
||||||
if (!prefixcmp(argv[i], "--sha1=")) {
|
|
||||||
ctx.qry.sha1 = xstrdup(argv[i] + 7);
|
ctx.qry.sha1 = xstrdup(argv[i] + 7);
|
||||||
ctx.qry.has_sha1 = 1;
|
ctx.qry.has_sha1 = 1;
|
||||||
}
|
} else if (!prefixcmp(argv[i], "--ofs=")) {
|
||||||
if (!prefixcmp(argv[i], "--ofs=")) {
|
|
||||||
ctx.qry.ofs = atoi(argv[i] + 6);
|
ctx.qry.ofs = atoi(argv[i] + 6);
|
||||||
}
|
} else if (!prefixcmp(argv[i], "--scan-tree=") ||
|
||||||
if (!prefixcmp(argv[i], "--scan-tree=") ||
|
|
||||||
!prefixcmp(argv[i], "--scan-path=")) {
|
!prefixcmp(argv[i], "--scan-path=")) {
|
||||||
/* HACK: the global snapshot bitmask defines the
|
/* HACK: the global snapshot bitmask defines the
|
||||||
* set of allowed snapshot formats, but the config
|
* set of allowed snapshot formats, but the config
|
||||||
|
Loading…
Reference in New Issue
Block a user