2
0
mirror of https://github.com/rehlds/reapi.git synced 2024-12-28 15:45:31 +03:00

Branch prediction optimization #2

This commit is contained in:
asmodai 2016-10-18 01:59:33 +03:00
parent f737fd201b
commit cc739f1551
3 changed files with 12 additions and 5 deletions

View File

@ -53,6 +53,7 @@ inline bool hasStringArgs() { return false; }
template <typename T, typename ...f_args>
bool hasStringArgs(T, f_args... args)
{
if (sizeof(T) > sizeof(int)) UTIL_SysError("%s: invalid hookchain argument size (%i > %i)", __FUNCTION__, sizeof(T), sizeof(int));
if (getApiType(T()) == ATYPE_STRING) return true;
return hasStringArgs(args...);
}
@ -257,7 +258,7 @@ template <typename R, typename original_t, typename ...f_args>
R callForward(size_t func, original_t original, f_args... args)
{
if (sizeof(R) > sizeof(int)) {
UTIL_SysError("%s: invalid return type size (%i)", __FUNCTION__, sizeof(R));
UTIL_SysError("%s: invalid return type size (%i > %i)", __FUNCTION__, sizeof(R), sizeof(int));
}
hookctx_t hookCtx(sizeof...(args), args...);

View File

@ -738,7 +738,7 @@ memberlist_t memberlist;
member_t *memberlist_t::operator[](size_t members) const
{
#define CASE(h) case mt_##h: if (index < arraysize(memberlist_##h)) return &memberlist_##h[index]; else break;
#define CASE(h) case mt_##h: if (likely(index < arraysize(memberlist_##h))) return &memberlist_##h[index]; else break;
const auto table = members_tables_e(members / MAX_REGION_RANGE);
const auto index = members & (MAX_REGION_RANGE - 1);

View File

@ -51,14 +51,20 @@ inline edict_t* edictByIndex(int index)
}
template<typename T>
T* getPrivate(int index)
inline T* getPrivate(int index)
{
return (T *)GET_PRIVATE(edictByIndexAmx(index));
T* pdata = nullptr;
if (likely(index >= 0))
pdata = (T *)g_pEdicts[index].pvPrivateData;
return pdata;
}
inline entvars_t* PEV(int index)
{
return VARS(edictByIndexAmx(index));
entvars_t* pvars = nullptr;
if (likely(index >= 0))
pvars = &g_pEdicts[index].v;
return pvars;
}
// HLTypeConversion.h -> AMXModX