Skip to content
Snippets Groups Projects
Verified Commit 9de800e8 authored by Kelsey Gilbert's avatar Kelsey Gilbert Committed by Pier Angelo Vendrame
Browse files

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
parent a7949831
No related branches found
No related tags found
1 merge request!1135Bug 43084: Rebased stable onto 115.15.0esr
......@@ -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");
}
// ----------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment