projects
/
oweals
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5fdf562
)
libs/lmo: fix whitespace handling in string hashing, optimize code
author
Jo-Philipp Wich
<jow@openwrt.org>
Fri, 23 Nov 2012 10:15:02 +0000
(10:15 +0000)
committer
Jo-Philipp Wich
<jow@openwrt.org>
Fri, 23 Nov 2012 10:15:02 +0000
(10:15 +0000)
libs/lmo/src/lmo_lualib.c
patch
|
blob
|
history
diff --git
a/libs/lmo/src/lmo_lualib.c
b/libs/lmo/src/lmo_lualib.c
index ade8e01f72321a0c210788239f3dc633fc89e3b9..5cc1e7d69ddaa58c97d40a20b0c06f0afd488028 100644
(file)
--- a/
libs/lmo/src/lmo_lualib.c
+++ b/
libs/lmo/src/lmo_lualib.c
@@
-55,17
+55,12
@@
static uint32_t _lmo_hash_string(lua_State *L, int n) {
if (!str || len >= sizeof(res))
return 0;
- while (*str && isspace(*str))
- str++;
-
- for (prev = 0, ptr = res; *str; prev = *str, str++)
+ for (prev = ' ', ptr = res; *str; prev = *str, str++)
{
if (isspace(*str))
{
- if (isspace(prev))
- continue;
-
- *ptr++ = ' ';
+ if (!isspace(prev))
+ *ptr++ = ' ';
}
else
{
@@
-73,7
+68,7
@@
static uint32_t _lmo_hash_string(lua_State *L, int n) {
}
}
-
while ((ptr > res) && isspace(*ptr
))
+
if ((ptr > res) && isspace(*(ptr-1)
))
ptr--;
return sfh_hash(res, ptr - res);