From 928800795ce2972d3df71480a70939806cd4d2e7 Mon Sep 17 00:00:00 2001 From: Silent Date: Tue, 20 Jun 2017 20:35:35 +0200 Subject: [PATCH] Branchless GetExtendedID --- SilentPatch/TheFLAUtils.cpp | 2 +- SilentPatch/TheFLAUtils.h | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/SilentPatch/TheFLAUtils.cpp b/SilentPatch/TheFLAUtils.cpp index 4a5e9d2..5eb375a 100644 --- a/SilentPatch/TheFLAUtils.cpp +++ b/SilentPatch/TheFLAUtils.cpp @@ -3,7 +3,7 @@ #define WIN32_LEAN_AND_MEAN #include -int32_t (*FLAUtils::GetExtendedIDFunc)(const void* ptr) = nullptr; +int32_t (*FLAUtils::GetExtendedIDFunc)(const void* ptr) = FLAUtils::GetExtendedID_Stock; void FLAUtils::Init() { diff --git a/SilentPatch/TheFLAUtils.h b/SilentPatch/TheFLAUtils.h index e41de87..6c9da0e 100644 --- a/SilentPatch/TheFLAUtils.h +++ b/SilentPatch/TheFLAUtils.h @@ -7,11 +7,7 @@ class FLAUtils public: static int32_t GetExtendedID(const void* ptr) { - if ( GetExtendedIDFunc != nullptr ) - return GetExtendedIDFunc(ptr); - - uint16_t uID = *static_cast(ptr); - return uID > MAX_UINT16_ID ? *static_cast(ptr) : uID; + return GetExtendedIDFunc(ptr); } static void Init(); @@ -19,5 +15,11 @@ public: private: static const int32_t MAX_UINT16_ID = 0xFFFD; + static int32_t GetExtendedID_Stock(const void* ptr) + { + uint16_t uID = *static_cast(ptr); + return uID > MAX_UINT16_ID ? *static_cast(ptr) : uID; + } + static int32_t (*GetExtendedIDFunc)(const void* ptr); }; \ No newline at end of file