lua-users home
lua-l archive

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


2017-10-15 17:43 GMT+02:00 Soni L. <fakedme@gmail.com>:
>
> I'm reading the Lua code, and it seems that Lua always checks the hash part,
> even for tables that don't use it. Why is this?

That's not how I read the code. Here are the comments and return
statements of luaH_next.

  /* find original element */
  /* try first array part */
  /* a non-nil value? */
 ...
      return 1;
    }
  /* hash part */
  /* a non-nil value? */
 ...
      return 1;
...
  return 0;  /* no more elements */

It's quite possible to return without reaching the code dealing with
the hash part.