[Scummvm-git-logs] scummvm master -> 7ebc284d3c8ef8b9192004d17655d60898e749db

sev- sev at scummvm.org
Fri Feb 3 09:14:03 CET 2017


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c3d533a72b SWORD25: Use direct integer index into indexTbl
7ebc284d3c Merge pull request #894 from wjp/lua_indexTbl


Commit: c3d533a72bedb469c42a3a8ee52830ac696a5533
    https://github.com/scummvm/scummvm/commit/c3d533a72bedb469c42a3a8ee52830ac696a5533
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2017-01-28T18:47:11+01:00

Commit Message:
SWORD25: Use direct integer index into indexTbl

This matches the behaviour of the Pluto rewrite Eris, and avoids
casting the integer indices to void *.

I verified this code by running this method in parallel with the current
lightuserdata/void* approach and asserting the retrieved objects were
identical when loading a savegame.

Changed paths:
    engines/sword25/util/lua_unpersist.cpp


diff --git a/engines/sword25/util/lua_unpersist.cpp b/engines/sword25/util/lua_unpersist.cpp
index 678ddb5..9c30450 100644
--- a/engines/sword25/util/lua_unpersist.cpp
+++ b/engines/sword25/util/lua_unpersist.cpp
@@ -116,16 +116,13 @@ static void registerObjectInIndexTable(UnSerializationInfo *info, int index) {
 	// >>>>> permTbl indexTbl ...... obj
 
 	// Make sure there is enough room on the stack
-	lua_checkstack(info->luaState, 2);
-
-	lua_pushlightuserdata(info->luaState, (void *)index);
-	// >>>>> permTbl indexTbl ...... obj index
+	lua_checkstack(info->luaState, 1);
 
-	lua_pushvalue(info->luaState, -2);
-	// >>>>> permTbl indexTbl ...... obj index obj
+	lua_pushvalue(info->luaState, -1);
+	// >>>>> permTbl indexTbl ...... obj obj
 
 	// Push the k/v pair into the indexTbl
-	lua_settable(info->luaState, 2);
+	lua_rawseti(info->luaState, 2, index);
 	// >>>>> permTbl indexTbl ...... obj
 }
 
@@ -198,10 +195,7 @@ static void unpersist(UnSerializationInfo *info) {
 		} else {
 			// Fetch the object from the indexTbl
 
-			lua_pushlightuserdata(info->luaState, (void *)index);
-			// >>>>> permTbl indexTbl ...... index
-
-			lua_gettable(info->luaState, 2);
+			lua_rawgeti(info->luaState, 2, index);
 			// >>>>> permTbl indexTbl ...... ?obj?
 
 			assert(!lua_isnil(info->luaState, -1));


Commit: 7ebc284d3c8ef8b9192004d17655d60898e749db
    https://github.com/scummvm/scummvm/commit/7ebc284d3c8ef8b9192004d17655d60898e749db
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2017-02-03T09:13:59+01:00

Commit Message:
Merge pull request #894 from wjp/lua_indexTbl

SWORD25: Use direct integer index into indexTbl

Changed paths:
    engines/sword25/util/lua_unpersist.cpp







More information about the Scummvm-git-logs mailing list