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

Side by Side Diff: third_party/WebKit/Source/wtf/text/WTFString.cpp

Issue 2655853003: Replace StringImpl::empty{16Bit}() with a static member (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights
4 * reserved. 4 * reserved.
5 * Copyright (C) 2007-2009 Torch Mobile, Inc. 5 * Copyright (C) 2007-2009 Torch Mobile, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 253
254 void String::ensure16Bit() { 254 void String::ensure16Bit() {
255 if (isNull()) 255 if (isNull())
256 return; 256 return;
257 if (!is8Bit()) 257 if (!is8Bit())
258 return; 258 return;
259 if (unsigned length = this->length()) 259 if (unsigned length = this->length())
260 m_impl = 260 m_impl =
261 make16BitFrom8BitSource(m_impl->characters8(), length).releaseImpl(); 261 make16BitFrom8BitSource(m_impl->characters8(), length).releaseImpl();
262 else 262 else
263 m_impl = StringImpl::empty16Bit(); 263 m_impl = StringImpl::empty16Bit;
264 } 264 }
265 265
266 void String::truncate(unsigned length) { 266 void String::truncate(unsigned length) {
267 if (m_impl) 267 if (m_impl)
268 m_impl = m_impl->truncate(length); 268 m_impl = m_impl->truncate(length);
269 } 269 }
270 270
271 void String::remove(unsigned start, unsigned lengthToRemove) { 271 void String::remove(unsigned start, unsigned lengthToRemove) {
272 if (m_impl) 272 if (m_impl)
273 m_impl = m_impl->remove(start, lengthToRemove); 273 m_impl = m_impl->remove(start, lengthToRemove);
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 } 778 }
779 779
780 String String::fromUTF8WithLatin1Fallback(const LChar* string, size_t size) { 780 String String::fromUTF8WithLatin1Fallback(const LChar* string, size_t size) {
781 String utf8 = fromUTF8(string, size); 781 String utf8 = fromUTF8(string, size);
782 if (!utf8) 782 if (!utf8)
783 return String(string, size); 783 return String(string, size);
784 return utf8; 784 return utf8;
785 } 785 }
786 786
787 const String& emptyString() { 787 const String& emptyString() {
788 DEFINE_STATIC_LOCAL(String, emptyString, (StringImpl::empty())); 788 DEFINE_STATIC_LOCAL(String, emptyString, (StringImpl::empty));
789 return emptyString; 789 return emptyString;
esprehn 2017/02/01 05:23:44 We should probably make these statics too.
Charlie Harrison 2017/02/01 05:29:48 Yeah I can probably do another patch for this, but
esprehn 2017/02/01 05:47:39 That seems like a reasonable thing to do. Add Stri
790 } 790 }
791 791
792 const String& emptyString16Bit() { 792 const String& emptyString16Bit() {
793 DEFINE_STATIC_LOCAL(String, emptyString, (StringImpl::empty16Bit())); 793 DEFINE_STATIC_LOCAL(String, emptyString, (StringImpl::empty16Bit));
794 return emptyString; 794 return emptyString;
795 } 795 }
796 796
797 std::ostream& operator<<(std::ostream& out, const String& string) { 797 std::ostream& operator<<(std::ostream& out, const String& string) {
798 if (string.isNull()) 798 if (string.isNull())
799 return out << "<null>"; 799 return out << "<null>";
800 800
801 out << '"'; 801 out << '"';
802 for (unsigned index = 0; index < string.length(); ++index) { 802 for (unsigned index = 0; index < string.length(); ++index) {
803 // Print shorthands for select cases. 803 // Print shorthands for select cases.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 return out << '"'; 836 return out << '"';
837 } 837 }
838 838
839 #ifndef NDEBUG 839 #ifndef NDEBUG
840 void String::show() const { 840 void String::show() const {
841 dataLogF("%s\n", asciiDebug(impl()).data()); 841 dataLogF("%s\n", asciiDebug(impl()).data());
842 } 842 }
843 #endif 843 #endif
844 844
845 } // namespace WTF 845 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/WTFString.h ('k') | third_party/WebKit/Source/wtf/text/WTFStringTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698