bug in loadlib.c?
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: bug in loadlib.c?
- From: Jack Pham <jackp@...>
- Date: 2009年9月04日 10:49:59 -0700
Hi,
This doesn't cause any errors but it looks like the creation of the
"package.loaders" table in luaopen_package() is calling
lua_createtable() incorrectly, with the "narr" and "nrec" parameters
swapped, perhaps leading to some unnecessary reallocation at load time?
--- loadlib.c 2008年08月06日 06:29:28.000000000 -0700
+++ loadlib.c.new 2009年09月04日 10:36:47.616920300 -0700
@@ -638,9 +638,9 @@
#endif
lua_pushvalue(L, -1);
lua_replace(L, LUA_ENVIRONINDEX);
/* create `loaders' table */
- lua_createtable(L, 0, sizeof(loaders)/sizeof(loaders[0]) - 1);
+ lua_createtable(L, sizeof(loaders)/sizeof(loaders[0]) - 1, 0);
/* fill it with pre-defined loaders */
for (i=0; loaders[i] != NULL; i++) {
lua_pushcfunction(L, loaders[i]);
lua_rawseti(L, -2, i+1);
In other words the table is initially constructed as a hash of
predetermined size but is best suited as an array as evidenced by the
calls to lua_rawseti().
Thanks,
Jack