From 3a354020e15ff154c44263ebb46670de2c9746b4 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 20 Dec 2013 18:52:15 -0500 Subject: [PATCH 1/3] Minimize calls into shell APIs --- Sources/Plasma/Apps/plClient/plClient.cpp | 25 +++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Sources/Plasma/Apps/plClient/plClient.cpp b/Sources/Plasma/Apps/plClient/plClient.cpp index 5ae7c507..5f4cce29 100644 --- a/Sources/Plasma/Apps/plClient/plClient.cpp +++ b/Sources/Plasma/Apps/plClient/plClient.cpp @@ -1279,19 +1279,28 @@ void plClient::IProgressMgrCallbackProc(plOperationProgress * progress) // Increments the taskbar progress [Windows 7+] #ifdef HS_BUILD_FOR_WIN32 - if (gTaskbarList) + if (gTaskbarList && fInstance->GetWindowHandle()) { - HWND hwnd = fInstance->GetWindowHandle(); // lazy + static TBPFLAG lastState = TBPF_NOPROGRESS; + TBPFLAG myState; + + // So, calling making these kernel calls is kind of SLOW. So, let's + // hide that behind a userland check--this helps linking go faster! if (progress->IsAborting()) - // We'll assume this is fatal - gTaskbarList->SetProgressState(hwnd, TBPF_ERROR); + myState = TBPF_ERROR; else if (progress->IsLastUpdate()) - gTaskbarList->SetProgressState(hwnd, TBPF_NOPROGRESS); + myState = TBPF_NOPROGRESS; else if (progress->GetMax() == 0.f) - gTaskbarList->SetProgressState(hwnd, TBPF_INDETERMINATE); + myState = TBPF_INDETERMINATE; else - // This will set TBPF_NORMAL for us - gTaskbarList->SetProgressValue(hwnd, (ULONGLONG)progress->GetProgress(), (ULONGLONG)progress->GetMax()); + myState = TBPF_NORMAL; + + if (myState == TBPF_NORMAL) + // This sets us to TBPF_NORMAL + gTaskbarList->SetProgressValue(fInstance->GetWindowHandle(), (ULONGLONG)progress->GetProgress(), (ULONGLONG)progress->GetMax()); + else if (myState != lastState) + gTaskbarList->SetProgressState(fInstance->GetWindowHandle(), myState); + lastState = myState; } #endif From 366a9a11a47f149352b601d7a8cc300f493acb29 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 20 Dec 2013 18:52:48 -0500 Subject: [PATCH 2/3] 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. From 88a60f04f6879be662d9e7ee3a4f7b9ece9c4150 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 20 Dec 2013 19:00:39 -0500 Subject: [PATCH 3/3] Inline plKey::operator== --- Sources/Plasma/NucleusLib/pnKeyedObject/plKey.cpp | 10 ---------- Sources/Plasma/NucleusLib/pnKeyedObject/plKey.h | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/plKey.cpp b/Sources/Plasma/NucleusLib/pnKeyedObject/plKey.cpp index 9f40017b..aced44a0 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/plKey.cpp +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/plKey.cpp @@ -204,16 +204,6 @@ plKey &plKey::operator=( const plKey &rhs ) return *this; } -bool plKey::operator==( const plKey &rhs ) const -{ - return fKeyData == rhs.fKeyData; -} - -bool plKey::operator==( const plKeyData *rhs ) const -{ - return fKeyData == rhs; -} - plKeyData *plKey::operator->() const { return fKeyData; diff --git a/Sources/Plasma/NucleusLib/pnKeyedObject/plKey.h b/Sources/Plasma/NucleusLib/pnKeyedObject/plKey.h index 26bc2a0b..ced49d31 100644 --- a/Sources/Plasma/NucleusLib/pnKeyedObject/plKey.h +++ b/Sources/Plasma/NucleusLib/pnKeyedObject/plKey.h @@ -67,8 +67,8 @@ public: ~plKey(); plKey& operator=(const plKey& rhs); - bool operator==(const plKey& rhs) const; - bool operator==(const plKeyData* rhs) const; + bool operator==(const plKey& rhs) const { return fKeyData == rhs.fKeyData; } + bool operator==(const plKeyData* rhs) const { return fKeyData == rhs; } bool operator!=(const plKey& rhs) const { return !(*this == rhs); } bool operator!=(const plKeyData* rhs) const { return !(*this == rhs); }