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

Unified Diff: third_party/WebKit/Source/wtf/text/AtomicStringTable.cpp

Issue 2103373002: Don't lazy allocate the AtomicStringTable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | « third_party/WebKit/Source/wtf/text/AtomicStringTable.h ('k') | third_party/WebKit/Source/wtf/wtf.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/text/AtomicStringTable.cpp
diff --git a/third_party/WebKit/Source/wtf/text/AtomicStringTable.cpp b/third_party/WebKit/Source/wtf/text/AtomicStringTable.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a4fa7c44bcef9e47747b4bf743909ec396ffc369
--- /dev/null
+++ b/third_party/WebKit/Source/wtf/text/AtomicStringTable.cpp
@@ -0,0 +1,39 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "wtf/text/AtomicStringTable.h"
+
+namespace WTF {
+
+AtomicStringTable::AtomicStringTable()
+{
+ for (StringImpl* string : StringImpl::allStaticStrings().values())
+ addStringImpl(string);
+}
+
+AtomicStringTable::~AtomicStringTable()
+{
+ for (StringImpl* string : m_table) {
+ if (!string->isStatic()) {
+ DCHECK(string->isAtomic());
+ string->setIsAtomic(false);
+ }
+ }
+}
+
+StringImpl* AtomicStringTable::addStringImpl(StringImpl* string)
+{
+ if (!string->length())
+ return StringImpl::empty();
+
+ StringImpl* result = *m_table.add(string).storedValue;
+
+ if (!result->isAtomic())
+ result->setIsAtomic(true);
+
+ DCHECK(!string->isStatic() || result->isStatic());
+ return result;
+}
+
+} // namespace WTF
« no previous file with comments | « third_party/WebKit/Source/wtf/text/AtomicStringTable.h ('k') | third_party/WebKit/Source/wtf/wtf.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698