From 366a9a11a47f149352b601d7a8cc300f493acb29 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 20 Dec 2013 18:52:48 -0500 Subject: [PATCH] Fix logic error that causes slow string lookup Recall that plKey object IDs are index-1 (unless they key is fixed, in which case the ID is always 0), whereas vectors are index-0. JOY TO THE HAX! --- Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp index d80f89d1..040b60c7 100644 --- a/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp +++ b/Sources/Plasma/PubUtilLib/plResMgr/plRegistryKeyList.cpp @@ -169,9 +169,11 @@ bool plRegistryKeyList::SetKeyUnused(plKeyImp* key, LoadStatus& loadStatusChange // Fixed Keys use ID == 0 if (id == 0) hsAssert(key->GetUoid().GetLocation() == plLocation::kGlobalFixedLoc, "key id == 0 but not fixed?"); - else if (id < fKeys.size()) { - if (fKeys[id]->GetUoid().GetObjectID() == id) - foundKey = fKeys[id]; + + // Recall that vectors are index zero but normal object IDs are index one... + else if (id <= fKeys.size()) { + if (fKeys[id-1]->GetUoid().GetObjectID() == id) + foundKey = fKeys[id-1]; } // Last chance: do a slow name search for that key.