Verified Commit 5cf6f906 authored by Kelsey Gilbert's avatar Kelsey Gilbert Committed by ma1
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 f7b58930
Loading
Loading
Loading
Loading
+7 −10
Original line number Original line Diff line number Diff line
@@ -17,15 +17,10 @@
namespace mozilla {
namespace mozilla {


const char* GetExtensionName(const WebGLExtensionID ext) {
const char* GetExtensionName(const WebGLExtensionID ext) {
  static EnumeratedArray<WebGLExtensionID, WebGLExtensionID::Max, const char*>
  switch (ext) {
      sExtensionNamesEnumeratedArray;
  static bool initialized = false;

  if (!initialized) {
    initialized = true;

#define WEBGL_EXTENSION_IDENTIFIER(x) \
#define WEBGL_EXTENSION_IDENTIFIER(x) \
  sExtensionNamesEnumeratedArray[WebGLExtensionID::x] = #x;
  case WebGLExtensionID::x:           \
    return #x;


    WEBGL_EXTENSION_IDENTIFIER(ANGLE_instanced_arrays)
    WEBGL_EXTENSION_IDENTIFIER(ANGLE_instanced_arrays)
    WEBGL_EXTENSION_IDENTIFIER(EXT_blend_minmax)
    WEBGL_EXTENSION_IDENTIFIER(EXT_blend_minmax)
@@ -67,9 +62,11 @@ const char* GetExtensionName(const WebGLExtensionID ext) {
    WEBGL_EXTENSION_IDENTIFIER(WEBGL_provoking_vertex)
    WEBGL_EXTENSION_IDENTIFIER(WEBGL_provoking_vertex)


#undef WEBGL_EXTENSION_IDENTIFIER
#undef WEBGL_EXTENSION_IDENTIFIER
  }


  return sExtensionNamesEnumeratedArray[ext];
    case WebGLExtensionID::Max:
      break;
  }
  MOZ_CRASH("bad WebGLExtensionID");
}
}


// ----------------------------
// ----------------------------