aboutsummaryrefslogtreecommitdiff
path: root/server.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-02-06 17:31:03 +0000
committerOmar Polo <op@omarpolo.com>2021-02-06 17:31:03 +0000
commitcd761624942ce5bd06fcf939400ed41b8166d37d (patch)
treebf05db683ca007e9015792960789b83163c82229 /server.c
parent6abda252e960943a302f7a945b1d008e463ea316 (diff)
swap check in vhost_* fns
it's faster (statistically speaking) to first compute if the option is set and then fnmatch than the inverse. This way we can avoid unnecessary fnmatch.
Diffstat (limited to 'server.c')
-rw-r--r--server.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/server.c b/server.c
index a25f0a7..ec44649 100644
--- a/server.c
+++ b/server.c
@@ -63,8 +63,8 @@ vhost_lang(struct vhost *v, const char *path)
return NULL;
for (loc = &v->locations[1]; loc->match != NULL; ++loc) {
- if (!fnmatch(loc->match, path, 0)) {
- if (loc->lang != NULL)
+ if (loc->lang != NULL) {
+ if (!fnmatch(loc->match, path, 0))
return loc->lang;
}
}
@@ -82,8 +82,8 @@ vhost_default_mime(struct vhost *v, const char *path)
return default_mime;
for (loc = &v->locations[1]; loc->match != NULL; ++loc) {
- if (!fnmatch(loc->match, path, 0)) {
- if (loc->default_mime != NULL)
+ if (loc->default_mime != NULL) {
+ if (!fnmatch(loc->match, path, 0))
return loc->default_mime;
}
}
@@ -103,8 +103,8 @@ vhost_index(struct vhost *v, const char *path)
return index;
for (loc = &v->locations[1]; loc->match != NULL; ++loc) {
- if (!fnmatch(loc->match, path, 0)) {
- if (loc->index != NULL)
+ if (loc->index != NULL) {
+ if (!fnmatch(loc->match, path, 0))
return loc->index;
}
}
@@ -123,8 +123,8 @@ vhost_auto_index(struct vhost *v, const char *path)
return 0;
for (loc = &v->locations[1]; loc->match != NULL; ++loc) {
- if (!fnmatch(loc->match, path, 0)) {
- if (loc->auto_index != 0)
+ if (loc->auto_index != 0) {
+ if (!fnmatch(loc->match, path, 0))
return loc->auto_index == 1;
}
}
@@ -141,8 +141,8 @@ vhost_block_return(struct vhost *v, const char *path, int *code, const char **fm
return 0;
for (loc = &v->locations[1]; loc->match != NULL; ++loc) {
- if (!fnmatch(loc->match, path, 0)) {
- if (loc->block_code != 0) {
+ if (loc->block_code != 0) {
+ if (!fnmatch(loc->match, path, 0)) {
*code = loc->block_code;
*fmt = loc->block_fmt;
return 1;
@@ -164,8 +164,8 @@ vhost_strip(struct vhost *v, const char *path)
return 0;
for (loc = &v->locations[1]; loc->match != NULL; ++loc) {
- if (!fnmatch(loc->match, path, 0)) {
- if (loc->strip != 0)
+ if (loc->strip != 0) {
+ if (!fnmatch(loc->match, path, 0))
return loc->strip;
}
}