mirror of
https://github.com/CookiePLMonster/SilentPatch.git
synced 2024-12-28 23:03:01 +05:00
Branchless GetExtendedID
This commit is contained in:
parent
35cc3a1562
commit
928800795c
2 changed files with 8 additions and 6 deletions
|
@ -3,7 +3,7 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
|
||||
int32_t (*FLAUtils::GetExtendedIDFunc)(const void* ptr) = nullptr;
|
||||
int32_t (*FLAUtils::GetExtendedIDFunc)(const void* ptr) = FLAUtils::GetExtendedID_Stock;
|
||||
|
||||
void FLAUtils::Init()
|
||||
{
|
||||
|
|
|
@ -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<const uint16_t*>(ptr);
|
||||
return uID > MAX_UINT16_ID ? *static_cast<const int16_t*>(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<const uint16_t*>(ptr);
|
||||
return uID > MAX_UINT16_ID ? *static_cast<const int16_t*>(ptr) : uID;
|
||||
}
|
||||
|
||||
static int32_t (*GetExtendedIDFunc)(const void* ptr);
|
||||
};
|
Loading…
Reference in a new issue