lua

A copy of the Lua development repository
Log | Files | Refs | README

commit f230898ad6f1d3fd1bc0216b2f4a504db112f2df
parent 3feb702df8b362d3d3a4bdeda48313da1278ebe4
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Mon, 23 Nov 2015 09:32:25 -0200

tiny code refactoring in 'luaS_hash'

Diffstat:
Mlstring.c | 7+++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git 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; }