aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2017-05-20 19:50:56 -0500
committerColin Snover2017-05-20 21:14:18 -0500
commit881be25fcd82d765235e95ebf041a70ec1ae5ae5 (patch)
tree23adf16b40a0d539b8ff54b2119cc5f52ea760bb
parent66efb750a0ccaa3c2ff8b77f60544a345328da8b (diff)
downloadscummvm-rg350-881be25fcd82d765235e95ebf041a70ec1ae5ae5.tar.gz
scummvm-rg350-881be25fcd82d765235e95ebf041a70ec1ae5ae5.tar.bz2
scummvm-rg350-881be25fcd82d765235e95ebf041a70ec1ae5ae5.zip
SCI: Stop making copies of ObjMap and remove related dead code
ObjMap owns Objects, so every time this map gets copied instead of referenced, it creates a copy of every single object in the associated script. This is expensive, and it breaks things like the `Object::syncBaseObject` call in savegame.cpp, which hasn't actually been doing anything since 58190c36b4cc84b3200239211d91b0291301db56 because it has been operating on copies.
-rw-r--r--engines/sci/console.cpp12
-rw-r--r--engines/sci/engine/object.h1
-rw-r--r--engines/sci/engine/savegame.cpp7
3 files changed, 7 insertions, 13 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index bc115341b7..0e90f22eba 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -2175,11 +2175,11 @@ bool Console::segmentInfo(int nr) {
else
debugPrintf(" Locals : none\n");
- ObjMap objects = scr->getObjectMap();
+ const ObjMap &objects = scr->getObjectMap();
debugPrintf(" Objects: %4d\n", objects.size());
- ObjMap::iterator it;
- const ObjMap::iterator end = objects.end();
+ ObjMap::const_iterator it;
+ const ObjMap::const_iterator end = objects.end();
for (it = objects.begin(); it != end; ++it) {
debugPrintf(" ");
// Object header
@@ -3546,9 +3546,9 @@ void Console::printKernelCallsFound(int kernelFuncNum, bool showFoundScripts) {
script = customSegMan->getScript(scriptSegment);
// Iterate through all the script's objects
- ObjMap objects = script->getObjectMap();
- ObjMap::iterator it;
- const ObjMap::iterator end = objects.end();
+ const ObjMap &objects = script->getObjectMap();
+ ObjMap::const_iterator it;
+ const ObjMap::const_iterator end = objects.end();
for (it = objects.begin(); it != end; ++it) {
const Object *obj = customSegMan->getObject(it->_value.getPos());
const char *objName = customSegMan->getObjectName(it->_value.getPos());
diff --git a/engines/sci/engine/object.h b/engines/sci/engine/object.h
index 136a831636..71b366dc79 100644
--- a/engines/sci/engine/object.h
+++ b/engines/sci/engine/object.h
@@ -309,7 +309,6 @@ public:
void initSpecies(SegManager *segMan, reg_t addr);
void initSuperClass(SegManager *segMan, reg_t addr);
bool initBaseObject(SegManager *segMan, reg_t addr, bool doInitSuperClass = true);
- void syncBaseObject(const SciSpan<const byte> &ptr) { _baseObj = ptr; }
#ifdef ENABLE_SCI32
bool mustSetViewVisible(const int index, const bool fromPropertyOp) const;
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index dce6430946..1095b7fe53 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -255,11 +255,6 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {
if (s.isLoading()) {
// Hook the script up in the script->segment map
_scriptSegMap[scr->getScriptNumber()] = i;
-
- ObjMap objects = scr->getObjectMap();
- for (ObjMap::iterator it = objects.begin(); it != objects.end(); ++it) {
- it->_value.syncBaseObject(scr->getSpan(it->_value.getPos().getOffset()));
- }
}
// Sync the script's string heap
@@ -287,7 +282,7 @@ void SegManager::saveLoadWithSerializer(Common::Serializer &s) {
Script *scr = (Script *)_heap[i];
scr->syncLocalsBlock(this);
- ObjMap objects = scr->getObjectMap();
+ ObjMap &objects = scr->getObjectMap();
for (ObjMap::iterator it = objects.begin(); it != objects.end(); ++it) {
reg_t addr = it->_value.getPos();
Object *obj = scr->scriptObjInit(addr, false);