- got rid of clearbuf.

This was used in only 4 places, 3 of which could easily be replaced with a memset, and the fourth, in the Strife status bar, suffering from a pointless performance optimization, rendering the code unreadable - the code spent here per frame is utterly insignificant so clarity should win here.

(cherry picked from commit 12a99c3f3c)
This commit is contained in:
Christoph Oelckers 2016-12-09 12:48:10 +01:00 committed by Rachael Alexanderson
parent 695b08ed4b
commit c61f30a627
6 changed files with 6 additions and 41 deletions

View file

@ -177,15 +177,6 @@ static inline SDWORD DivScale30 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)
static inline SDWORD DivScale31 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 31) / b); } static inline SDWORD DivScale31 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 31) / b); }
static inline SDWORD DivScale32 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 32) / b); } static inline SDWORD DivScale32 (SDWORD a, SDWORD b) { return (SDWORD)(((SQWORD)a << 32) / b); }
static __forceinline void clearbuf (void *buff, unsigned int count, SDWORD clear)
{
SDWORD *b2 = (SDWORD *)buff;
for (unsigned int i = 0; i != count; ++i)
{
b2[i] = clear;
}
}
static __forceinline void clearbufshort (void *buff, unsigned int count, WORD clear) static __forceinline void clearbufshort (void *buff, unsigned int count, WORD clear)
{ {
SWORD *b2 = (SWORD *)buff; SWORD *b2 = (SWORD *)buff;

View file

@ -169,14 +169,10 @@ void FHealthBar::MakeTexture ()
void FHealthBar::FillBar (int min, int max, BYTE light, BYTE dark) void FHealthBar::FillBar (int min, int max, BYTE light, BYTE dark)
{ {
#ifdef __BIG_ENDIAN__ for (int i = min*2; i < max*2; i++)
SDWORD fill = (light << 24) | (dark << 16) | (light << 8) | dark;
#else
SDWORD fill = light | (dark << 8) | (light << 16) | (dark << 24);
#endif
if (max > min)
{ {
clearbuf (&Pixels[min*4], max - min, fill); Pixels[i * 2] = light;
Pixels[i * 2 + 1] = dark;
} }
} }

View file

@ -291,19 +291,6 @@ static inline SDWORD DivScale32 (SDWORD a, SDWORD b)
return result; return result;
} }
static inline void clearbuf (void *buff, int count, SDWORD clear)
{
int dummy1, dummy2;
asm volatile
("rep stosl"
:"=D" (dummy1),
"=c" (dummy2)
: "D" (buff),
"c" (count),
"a" (clear)
);
}
static inline void clearbufshort (void *buff, unsigned int count, WORD clear) static inline void clearbufshort (void *buff, unsigned int count, WORD clear)
{ {
asm volatile asm volatile

View file

@ -321,15 +321,6 @@ __forceinline SDWORD DivScale32 (SDWORD a, SDWORD b)
__asm idiv b __asm idiv b
} }
__forceinline void clearbuf (void *buff, unsigned int count, SDWORD clear)
{
SDWORD *b2 = (SDWORD *)buff;
for (unsigned int i = 0; i != count; ++i)
{
b2[i] = clear;
}
}
__forceinline void clearbufshort (void *buff, unsigned int count, WORD clear) __forceinline void clearbufshort (void *buff, unsigned int count, WORD clear)
{ {
SWORD *b2 = (SWORD *)buff; SWORD *b2 = (SWORD *)buff;

View file

@ -925,7 +925,7 @@ void FBlockThingsIterator::init(const FBoundingBox &box)
void FBlockThingsIterator::ClearHash() void FBlockThingsIterator::ClearHash()
{ {
clearbuf(Buckets, countof(Buckets), -1); memset(Buckets, -1, sizeof(Buckets));
NumFixedHash = 0; NumFixedHash = 0;
DynHash.Clear(); DynHash.Clear();
} }

View file

@ -270,7 +270,7 @@ void R_InitSpriteDefs ()
// Create a hash table to speed up the process // Create a hash table to speed up the process
smax = TexMan.NumTextures(); smax = TexMan.NumTextures();
hashes = new Hasher[smax]; hashes = new Hasher[smax];
clearbuf(hashes, sizeof(Hasher)*smax/4, -1); memset(hashes, -1, sizeof(Hasher)*smax);
for (i = 0; i < smax; ++i) for (i = 0; i < smax; ++i)
{ {
FTexture *tex = TexMan.ByIndex(i); FTexture *tex = TexMan.ByIndex(i);
@ -285,7 +285,7 @@ void R_InitSpriteDefs ()
// Repeat, for voxels // Repeat, for voxels
vmax = Wads.GetNumLumps(); vmax = Wads.GetNumLumps();
vhashes = new VHasher[vmax]; vhashes = new VHasher[vmax];
clearbuf(vhashes, sizeof(VHasher)*vmax/4, -1); memset(vhashes, -1, sizeof(VHasher)*vmax);
for (i = 0; i < vmax; ++i) for (i = 0; i < vmax; ++i)
{ {
if (Wads.GetLumpNamespace(i) == ns_voxels) if (Wads.GetLumpNamespace(i) == ns_voxels)