Bug 1063754. Cache result of Factory::HasSSE2(). r=bas

--HG--
extra : rebase_source : 3d25afdc6d679303ea1b73cc9ef1dbd9b971c5c0
This commit is contained in:
Robert O'Callahan 2014-09-06 16:16:06 +12:00
parent 8432077b40
commit b54cad168f

View File

@ -178,7 +178,16 @@ Factory::HasSSE2()
// cl.exe with -arch:SSE2 (default on x64 compiler)
return true;
#elif defined(HAVE_CPU_DETECTION)
return HasCPUIDBit(1u, edx, (1u<<26));
static enum {
UNINITIALIZED,
NO_SSE2,
HAS_SSE2
} sDetectionState = UNINITIALIZED;
if (sDetectionState == UNINITIALIZED) {
sDetectionState = HasCPUIDBit(1u, edx, (1u<<26)) ? HAS_SSE2 : NO_SSE2;
}
return sDetectionState == HAS_SSE2;
#else
return false;
#endif