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

Side by Side Diff: Source/wtf/text/StringImpl.h

Issue 587173005: Add WTF::String::emptyString16Bit (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | Source/wtf/text/StringStatics.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
4 * Copyright (C) 2009 Google Inc. All rights reserved. 4 * Copyright (C) 2009 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 , m_is8Bit(true) 134 , m_is8Bit(true)
135 , m_isStatic(true) 135 , m_isStatic(true)
136 { 136 {
137 // Ensure that the hash is computed so that AtomicStringHash can call ex istingHash() 137 // Ensure that the hash is computed so that AtomicStringHash can call ex istingHash()
138 // with impunity. The empty string is special because it is never entere d into 138 // with impunity. The empty string is special because it is never entere d into
139 // AtomicString's HashKey, but still needs to compare correctly. 139 // AtomicString's HashKey, but still needs to compare correctly.
140 STRING_STATS_ADD_8BIT_STRING(m_length); 140 STRING_STATS_ADD_8BIT_STRING(m_length);
141 hash(); 141 hash();
142 } 142 }
143 143
144 enum ConstructEmptyString16BitTag { ConstructEmptyString16Bit };
145 explicit StringImpl(ConstructEmptyString16BitTag)
146 : m_refCount(1)
147 , m_length(0)
148 , m_hash(0)
149 , m_isAtomic(false)
150 , m_is8Bit(false)
151 , m_isStatic(true)
152 {
153 STRING_STATS_ADD_16BIT_STRING(m_length);
154 hash();
155 }
156
144 // FIXME: there has to be a less hacky way to do this. 157 // FIXME: there has to be a less hacky way to do this.
145 enum Force8Bit { Force8BitConstructor }; 158 enum Force8Bit { Force8BitConstructor };
146 StringImpl(unsigned length, Force8Bit) 159 StringImpl(unsigned length, Force8Bit)
147 : m_refCount(1) 160 : m_refCount(1)
148 , m_length(length) 161 , m_length(length)
149 , m_hash(0) 162 , m_hash(0)
150 , m_isAtomic(false) 163 , m_isAtomic(false)
151 , m_is8Bit(true) 164 , m_is8Bit(true)
152 , m_isStatic(false) 165 , m_isStatic(false)
153 { 166 {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 { 297 {
285 if (hasOneRef()) { 298 if (hasOneRef()) {
286 destroyIfNotStatic(); 299 destroyIfNotStatic();
287 return; 300 return;
288 } 301 }
289 302
290 --m_refCount; 303 --m_refCount;
291 } 304 }
292 305
293 static StringImpl* empty(); 306 static StringImpl* empty();
307 static StringImpl* empty16Bit();
294 308
295 // FIXME: Does this really belong in StringImpl? 309 // FIXME: Does this really belong in StringImpl?
296 template <typename T> static void copyChars(T* destination, const T* source, unsigned numCharacters) 310 template <typename T> static void copyChars(T* destination, const T* source, unsigned numCharacters)
297 { 311 {
298 memcpy(destination, source, numCharacters * sizeof(T)); 312 memcpy(destination, source, numCharacters * sizeof(T));
299 } 313 }
300 314
301 ALWAYS_INLINE static void copyChars(UChar* destination, const LChar* source, unsigned numCharacters) 315 ALWAYS_INLINE static void copyChars(UChar* destination, const LChar* source, unsigned numCharacters)
302 { 316 {
303 for (unsigned i = 0; i < numCharacters; ++i) 317 for (unsigned i = 0; i < numCharacters; ++i)
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } 745 }
732 746
733 using WTF::StringImpl; 747 using WTF::StringImpl;
734 using WTF::equal; 748 using WTF::equal;
735 using WTF::equalNonNull; 749 using WTF::equalNonNull;
736 using WTF::TextCaseSensitivity; 750 using WTF::TextCaseSensitivity;
737 using WTF::TextCaseSensitive; 751 using WTF::TextCaseSensitive;
738 using WTF::TextCaseInsensitive; 752 using WTF::TextCaseInsensitive;
739 753
740 #endif 754 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/wtf/text/StringStatics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698