The 22% gain was seen comparing 10 GetLocalInt() calls on an object with 10 local integers to 4 GetLocalInt() calls, 10 GetPiecewiseInteger() calls on an object with 4 local integers. 22% was the gain over 100,000 iterations.
Normal code:
Code: Select all
GetLocalInt(OBJECT_SELF, "V0");
GetLocalInt(OBJECT_SELF, "V1");
GetLocalInt(OBJECT_SELF, "V2");
GetLocalInt(OBJECT_SELF, "V3");
GetLocalInt(OBJECT_SELF, "V4");
GetLocalInt(OBJECT_SELF, "V5");
GetLocalInt(OBJECT_SELF, "V6");
GetLocalInt(OBJECT_SELF, "V7");
GetLocalInt(OBJECT_SELF, "V8");
GetLocalInt(OBJECT_SELF, "V9");
...
Code: Select all
v0 = GetLocalInt(OBJECT_SELF, "V0");
v1 = GetLocalInt(OBJECT_SELF, "V1");
v2 = GetLocalInt(OBJECT_SELF, "V2");
GetPiecewiseInteger(v0, 0, 7);
GetPiecewiseInteger(v0, 8, 15);
GetPiecewiseInteger(v0, 16, 23);
GetPiecewiseInteger(v0, 24, 31);
GetPiecewiseInteger(v1, 0, 7);
GetPiecewiseInteger(v1, 8, 15);
GetPiecewiseInteger(v1, 16, 23);
GetPiecewiseInteger(v1, 24, 31);
GetPiecewiseInteger(v2, 0, 7);
GetPiecewiseInteger(v2, 8, 15);
...
Code: Select all
int GetPiecewiseInteger(int nNum, int nStartBit, int nEndBit) {
nNum = nNum << nEndBit;
return ( nNum >>> (nStartBit + nEndBit) );
}