mirror of
https://github.com/yuzu-emu/FasTC
synced 2024-11-26 02:07:56 +00:00
Add a few assumptions for performance
This commit is contained in:
parent
d3f5eeab87
commit
77a78511c6
1 changed files with 13 additions and 4 deletions
|
@ -67,18 +67,27 @@ class Indexer {
|
||||||
const uint32 m_Height;
|
const uint32 m_Height;
|
||||||
|
|
||||||
uint32 Resolve(int32 i, uint32 limit) const {
|
uint32 Resolve(int32 i, uint32 limit) const {
|
||||||
|
int32 l = static_cast<int32>(limit);
|
||||||
|
|
||||||
|
// Assumptions
|
||||||
|
assert(i > -l);
|
||||||
|
assert(i < 2*l);
|
||||||
|
|
||||||
int32 r;
|
int32 r;
|
||||||
switch(m_WrapMode) {
|
switch(m_WrapMode) {
|
||||||
case eWrapMode_Clamp:
|
case eWrapMode_Clamp:
|
||||||
r = static_cast<uint32>(std::max(0, std::min<int32>(i, limit)));
|
r = static_cast<uint32>(std::max(0, std::min(i, l)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eWrapMode_Wrap:
|
case eWrapMode_Wrap:
|
||||||
{
|
{
|
||||||
r = i;
|
r = i;
|
||||||
int32 l = static_cast<int32>(limit);
|
if ((l & (l-1)) == 0) {
|
||||||
while (r >= l) { r -= l; }
|
r = (r + l) & (l - 1);
|
||||||
while (r < 0) { r += l; }
|
} else {
|
||||||
|
if (r >= l) { r -= l; }
|
||||||
|
if (r < 0) { r += l; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue