Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: src/core/SkData.cpp

Issue 26491003: SK_ONCE for SkData (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: dropped assert Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkPathRef.h ('k') | src/core/SkMatrix.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkData.cpp
diff --git a/src/core/SkData.cpp b/src/core/SkData.cpp
index 8d6156c7f2969bca3413eeb766482b40ab7c4ca8..56c1256d7524fe8b09ffac0cff30f5d4e2aeb4a1 100644
--- a/src/core/SkData.cpp
+++ b/src/core/SkData.cpp
@@ -8,6 +8,7 @@
#include "SkData.h"
#include "SkFlattenableBuffers.h"
#include "SkOSFile.h"
+#include "SkOnce.h"
SK_DEFINE_INST_COUNT(SkData)
@@ -49,11 +50,14 @@ size_t SkData::copyRange(size_t offset, size_t length, void* buffer) const {
///////////////////////////////////////////////////////////////////////////////
+void SkData::NewEmptyImpl(SkData** empty) {
+ *empty = new SkData(NULL, 0, NULL, NULL);
+}
+
SkData* SkData::NewEmpty() {
static SkData* gEmptyRef;
- if (NULL == gEmptyRef) {
- gEmptyRef = new SkData(NULL, 0, NULL, NULL);
- }
+ SK_DECLARE_STATIC_ONCE(once);
+ SkOnce(&once, SkData::NewEmptyImpl, &gEmptyRef);
gEmptyRef->ref();
return gEmptyRef;
}
« no previous file with comments | « include/core/SkPathRef.h ('k') | src/core/SkMatrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698