From 9e8a6ec2b5e52e0be446498ad82e0218cef73cb1 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 22 Feb 2018 13:58:20 +0100 Subject: [PATCH] gluon-web: remove lmo_canon_hash() Our strings can be looked up verbatim. --- package/gluon-web/src/template_lmo.c | 30 +--------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/package/gluon-web/src/template_lmo.c b/package/gluon-web/src/template_lmo.c index 8cff1a33..e156fd22 100644 --- a/package/gluon-web/src/template_lmo.c +++ b/package/gluon-web/src/template_lmo.c @@ -69,34 +69,6 @@ static uint32_t sfh_hash(const char *data, int len) return hash; } -static uint32_t lmo_canon_hash(const char *str, int len) -{ - char res[4096]; - char *ptr, prev; - int off; - - if (!str || len >= sizeof(res)) - return 0; - - for (prev = ' ', ptr = res, off = 0; off < len; prev = *str, off++, str++) - { - if (isspace(*str)) - { - if (!isspace(prev)) - *ptr++ = ' '; - } - else - { - *ptr++ = *str; - } - } - - if ((ptr > res) && isspace(*(ptr-1))) - ptr--; - - return sfh_hash(res, ptr - res); -} - static lmo_archive_t * lmo_open(const char *file) { int in = -1; @@ -272,7 +244,7 @@ int lmo_translate(const char *key, int keylen, char **out, int *outlen) if (!key || !_lmo_active_catalog) return -2; - hash = lmo_canon_hash(key, keylen); + hash = sfh_hash(key, keylen); for (ar = _lmo_active_catalog->archives; ar; ar = ar->next) {