summaryrefslogtreecommitdiff
path: root/src/stat_cache.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2017-05-11 23:15:29 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2017-05-15 22:02:33 -0400
commit86bb8be2c8eb5a65ebf73f12f62833db84d2cf9c (patch)
tree3876eda09b6d08c143c83422f18478f0997900d2 /src/stat_cache.c
parent07cde2cf0b290cdbbf6528e3ecf106297615f754 (diff)
downloadlighttpd1.4-86bb8be2c8eb5a65ebf73f12f62833db84d2cf9c.tar.gz
lighttpd1.4-86bb8be2c8eb5a65ebf73f12f62833db84d2cf9c.zip
[core] perf: skip redundant strlen() if len known
performance: skip redundant strlen() if length is already known introduce array_get_element_klen() to take key and klen params
Diffstat (limited to 'src/stat_cache.c')
-rw-r--r--src/stat_cache.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/stat_cache.c b/src/stat_cache.c
index 732e3cf3..882ba6d4 100644
--- a/src/stat_cache.c
+++ b/src/stat_cache.c
@@ -292,19 +292,19 @@ const buffer * stat_cache_mimetype_by_ext(const connection *con, const char *nam
s = name;
}
/* search for basename, then longest .ext2.ext1, then .ext1, then "" */
- ds = (data_string *)array_get_element(con->conf.mimetypes, s);
+ ds = (data_string *)array_get_element_klen(con->conf.mimetypes, s, end - s);
if (NULL != ds) return ds->value;
while (++s < end) {
while (*s != '.' && ++s != end) ;
if (s == end) break;
/* search ".ext" then "ext" */
- ds = (data_string *)array_get_element(con->conf.mimetypes, s);
+ ds = (data_string *)array_get_element_klen(con->conf.mimetypes, s, end - s);
if (NULL != ds) return ds->value;
/* repeat search without leading '.' to handle situation where
* admin configured mimetype.assign keys without leading '.' */
if (++s < end) {
if (*s == '.') { --s; continue; }
- ds = (data_string *)array_get_element(con->conf.mimetypes, s);
+ ds = (data_string *)array_get_element_klen(con->conf.mimetypes, s, end - s);
if (NULL != ds) return ds->value;
}
}