lua-users home
lua-l archive

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


a minor improvement/optimization of setpath().

François
diff --git a/src/loadlib.c b/src/loadlib.c
index ce3c2e6..a7f1cfb 100644
--- a/src/loadlib.c
+++ b/src/loadlib.c
@@ -599,8 +599,8 @@ static void setpath (lua_State *L, const char *fieldname, const char *envname1,
     /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */
     path = luaL_gsub(L, path, LUA_PATH_SEP LUA_PATH_SEP,
                               LUA_PATH_SEP AUXMARK LUA_PATH_SEP);
+    lua_remove(L, -1);
     luaL_gsub(L, path, AUXMARK, def);
-    lua_remove(L, -2);
   }
   setprogdir(L);
   lua_setfield(L, -2, fieldname);