From 881be25fcd82d765235e95ebf041a70ec1ae5ae5 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Sat, 20 May 2017 19:50:56 -0500 Subject: 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. --- engines/sci/engine/object.h | 1 - engines/sci/engine/savegame.cpp | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) (limited to 'engines/sci/engine') 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 &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); -- cgit v1.2.3