aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Bruce Dawson <brucedawson@google.com>2017-01-22 12:43:53 -0800
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-23 15:26:28 +0000
commitb07a01e6b9bd552bab12aabd48dc77a7562f4f97 (patch)
treedaf5d768d9282238c9780708ab6288fb517e180e
parent977f64cbfad1ecd7fd4b1231c694c7e828fda1f0 (diff)
Get rid of level of indirection, noticed by VC++ 2017 bug
When building Chrome with VC++ 2017 the QuickFDot6Inverse::table pointer is initialized to zero. This is certainly a bug, and it has been reported to the VC++ team. But, the table pointer appears to be unnecessary. Changing the code to reference the array directly should give identical or perhaps even better code. The change to the array indexing code is as follows: - return table[x]; + gFDot6INVERSE[kInverseTableSize + x]; This looks like a step backwards, but it isn't. 'table' is a pointer. So, by default the compiler will load this pointer and then load the value from the array. gFDot6INVERSE is an array, not a pointer. This means that the adding of kInverseTableSize is trivially done at compile time, and there is no loading of a pointer - only one data segment memory access is needed. The compiler may have realized that this optimization was ready before, but now it is more trivial. And, this works around the VC++ 2017 bug so that Chrome with VC++ 2017 will launch. https://connect.microsoft.com/VisualStudio/feedback/details/3119337 BUG=683729 Change-Id: Iad443b59a70af83b39260e244e3242e782fafdbb Reviewed-on: https://skia-review.googlesource.com/7284 Reviewed-by: Yuqian Li <liyuqian@google.com> Commit-Queue: Yuqian Li <liyuqian@google.com>
-rw-r--r--src/core/SkFDot6.h4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/core/SkFDot6.h b/src/core/SkFDot6.h
index b9a5c2a12d..004666115e 100644
--- a/src/core/SkFDot6.h
+++ b/src/core/SkFDot6.h
@@ -78,12 +78,10 @@ inline SkFixed SkFDot6Div(SkFDot6 a, SkFDot6 b) {
#include "SkFDot6Constants.h"
class QuickFDot6Inverse {
-private:
- static constexpr const SkFDot6* table = gFDot6INVERSE + kInverseTableSize;
public:
inline static SkFixed Lookup(SkFDot6 x) {
SkASSERT(SkAbs32(x) < kInverseTableSize);
- return table[x];
+ return gFDot6INVERSE[kInverseTableSize + x];
}
};