aboutsummaryrefslogtreecommitdiffstats
path: root/cgit.c
diff options
context:
space:
mode:
authorLukas Fleischer2014-01-10 14:55:30 +0100
committerJason A. Donenfeld2014-01-10 17:05:34 +0100
commit441e748564aff49932d02987cd2bdcfbb623c295 (patch)
tree39a22d071da1af3d3621fe4d35d3492d68bc106c /cgit.c
parente711679618ce704633f09bc10d2fe85291054536 (diff)
downloadcgit-441e748564aff49932d02987cd2bdcfbb623c295.tar.gz
cgit-441e748564aff49932d02987cd2bdcfbb623c295.tar.bz2
cgit-441e748564aff49932d02987cd2bdcfbb623c295.zip
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>
Diffstat (limited to 'cgit.c')
-rw-r--r--cgit.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/cgit.c b/cgit.c
index e31962d..f4262d8 100644
--- a/cgit.c
+++ b/cgit.c
@@ -865,35 +865,26 @@ static void cgit_parse_args(int argc, const char **argv)
865 for (i = 1; i < argc; i++) { 865 for (i = 1; i < argc; i++) {
866 if (!prefixcmp(argv[i], "--cache=")) { 866 if (!prefixcmp(argv[i], "--cache=")) {
867 ctx.cfg.cache_root = xstrdup(argv[i] + 8); 867 ctx.cfg.cache_root = xstrdup(argv[i] + 8);
868 } 868 } else if (!strcmp(argv[i], "--nocache")) {
869 if (!strcmp(argv[i], "--nocache")) {
870 ctx.cfg.nocache = 1; 869 ctx.cfg.nocache = 1;
871 } 870 } else if (!strcmp(argv[i], "--nohttp")) {
872 if (!strcmp(argv[i], "--nohttp")) {
873 ctx.env.no_http = "1"; 871 ctx.env.no_http = "1";
874 } 872 } else if (!prefixcmp(argv[i], "--query=")) {
875 if (!prefixcmp(argv[i], "--query=")) {
876 ctx.qry.raw = xstrdup(argv[i] + 8); 873 ctx.qry.raw = xstrdup(argv[i] + 8);
877 } 874 } else if (!prefixcmp(argv[i], "--repo=")) {
878 if (!prefixcmp(argv[i], "--repo=")) {
879 ctx.qry.repo = xstrdup(argv[i] + 7); 875 ctx.qry.repo = xstrdup(argv[i] + 7);
880 } 876 } else if (!prefixcmp(argv[i], "--page=")) {
881 if (!prefixcmp(argv[i], "--page=")) {
882 ctx.qry.page = xstrdup(argv[i] + 7); 877 ctx.qry.page = xstrdup(argv[i] + 7);
883 } 878 } else if (!prefixcmp(argv[i], "--head=")) {
884 if (!prefixcmp(argv[i], "--head=")) {
885 ctx.qry.head = xstrdup(argv[i] + 7); 879 ctx.qry.head = xstrdup(argv[i] + 7);
886 ctx.qry.has_symref = 1; 880 ctx.qry.has_symref = 1;
887 } 881 } else if (!prefixcmp(argv[i], "--sha1=")) {
888 if (!prefixcmp(argv[i], "--sha1=")) {
889 ctx.qry.sha1 = xstrdup(argv[i] + 7); 882 ctx.qry.sha1 = xstrdup(argv[i] + 7);
890 ctx.qry.has_sha1 = 1; 883 ctx.qry.has_sha1 = 1;
891 } 884 } else if (!prefixcmp(argv[i], "--ofs=")) {
892 if (!prefixcmp(argv[i], "--ofs=")) {
893 ctx.qry.ofs = atoi(argv[i] + 6); 885 ctx.qry.ofs = atoi(argv[i] + 6);
894 } 886 } else if (!prefixcmp(argv[i], "--scan-tree=") ||
895 if (!prefixcmp(argv[i], "--scan-tree=") || 887 !prefixcmp(argv[i], "--scan-path=")) {
896 !prefixcmp(argv[i], "--scan-path=")) {
897 /* HACK: the global snapshot bitmask defines the 888 /* HACK: the global snapshot bitmask defines the
898 * set of allowed snapshot formats, but the config 889 * set of allowed snapshot formats, but the config
899 * file hasn't been parsed yet so the mask is 890 * file hasn't been parsed yet so the mask is