lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


** Hash for integers. To allow a good hash, use the remainder operator

** ('%'). If integer fits as a non-negative int, compute an int

** remainder, which is faster. Otherwise, use an unsigned-integer

** remainder, which uses all bits and ensures a non-negative result.



static Node *hashint (const Table *t, lua_Integer i) {

  lua_Unsigned ui = l_castS2U(i);

  if (ui <= (unsigned int)INT_MAX)

    return hashmod(t, cast_int(ui));  //------------------------------------------      


    return hashmod(t, ui);



Hi I'm a little confused  ..

Why do you want to use“cast_int“ to force “ui” to int

Is it because it's faster to convert from unsigned long long to int