mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1819497 - Don't race on static bool for initialization. r=gfx-reviewers,aosmond
We could do non-racy static init here (e.g. with a static initializer self-calling-closure), but there doesn't seem to be a strong reason for this. Let's just use a switch and get robustness from -Werror=switch. Differential Revision: https://phabricator.services.mozilla.com/D188054
This commit is contained in:
parent
b29bd01391
commit
ce8432a312
@ -17,15 +17,10 @@
|
||||
namespace mozilla {
|
||||
|
||||
const char* GetExtensionName(const WebGLExtensionID ext) {
|
||||
static EnumeratedArray<WebGLExtensionID, WebGLExtensionID::Max, const char*>
|
||||
sExtensionNamesEnumeratedArray;
|
||||
static bool initialized = false;
|
||||
|
||||
if (!initialized) {
|
||||
initialized = true;
|
||||
|
||||
switch (ext) {
|
||||
#define WEBGL_EXTENSION_IDENTIFIER(x) \
|
||||
sExtensionNamesEnumeratedArray[WebGLExtensionID::x] = #x;
|
||||
case WebGLExtensionID::x: \
|
||||
return #x;
|
||||
|
||||
WEBGL_EXTENSION_IDENTIFIER(ANGLE_instanced_arrays)
|
||||
WEBGL_EXTENSION_IDENTIFIER(EXT_blend_minmax)
|
||||
@ -67,9 +62,11 @@ const char* GetExtensionName(const WebGLExtensionID ext) {
|
||||
WEBGL_EXTENSION_IDENTIFIER(WEBGL_provoking_vertex)
|
||||
|
||||
#undef WEBGL_EXTENSION_IDENTIFIER
|
||||
}
|
||||
|
||||
return sExtensionNamesEnumeratedArray[ext];
|
||||
case WebGLExtensionID::Max:
|
||||
break;
|
||||
}
|
||||
MOZ_CRASH("bad WebGLExtensionID");
|
||||
}
|
||||
|
||||
// ----------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user