Statically initialize those zero-size singletons.
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 7 May 2014 19:15:01 +0000 (19:15 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 7 May 2014 19:15:01 +0000 (19:15 +0000)
This way GCC/Clang don't generate the magic static code to call the
pointless T::T() once in a threadsafe way.  = {} is plenty initialized.

BUG=skia:2378
R=bungeman@google.com, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/270353003

git-svn-id: http://skia.googlecode.com/svn/trunk@14623 2bbb7eff-a529-9590-31e7-b0007b416f81

src/record/SkRecord.h
src/record/SkRecords.h

index ccfa1dd..068155e 100644 (file)
@@ -167,7 +167,7 @@ private:
     // We could just return NULL but it's sort of confusing to return NULL on success.
     template <typename T>
     SK_WHEN(SkTIsEmpty<T>, T*) allocCommand() {
-        static T singleton;
+        static T singleton = {};
         return &singleton;
     }
 
index bfa1549..d4b6852 100644 (file)
@@ -63,7 +63,6 @@ enum Type { SK_RECORD_TYPES(ENUM) };
 #define RECORD0(T)                      \
 struct T {                              \
     static const Type kType = T##_Type; \
-    T() {}                              \
 };
 
 // We try to be flexible about the types the constructors take.  Instead of requring the exact type