From f230898ad6f1d3fd1bc0216b2f4a504db112f2df Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 23 Nov 2015 09:32:51 -0200 Subject: tiny code refactoring in 'luaS_hash' --- lstring.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lstring.c') diff --git a/lstring.c b/lstring.c index 6760b97d..fc9eb220 100644 --- a/lstring.c +++ b/lstring.c @@ -1,5 +1,5 @@ /* -** $Id: lstring.c,v 2.54 2015/10/08 15:53:31 roberto Exp roberto $ +** $Id: lstring.c,v 2.55 2015/11/03 15:36:01 roberto Exp roberto $ ** String table (keeps all strings handled by Lua) ** See Copyright Notice in lua.h */ @@ -48,10 +48,9 @@ int luaS_eqlngstr (TString *a, TString *b) { unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) { unsigned int h = seed ^ cast(unsigned int, l); - size_t l1; size_t step = (l >> LUAI_HASHLIMIT) + 1; - for (l1 = l; l1 >= step; l1 -= step) - h = h ^ ((h<<5) + (h>>2) + cast_byte(str[l1 - 1])); + for (; l >= step; l -= step) + h ^= ((h<<5) + (h>>2) + cast_byte(str[l - 1])); return h; } -- cgit v1.2.3-55-g6feb