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

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

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
« Source/wtf/text/WTFString.h ('K') | « Source/wtf/text/WTFString.h ('k') | no next file » | 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 * (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 reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights reserved.
4 * Copyright (C) 2007-2009 Torch Mobile, Inc. 4 * Copyright (C) 2007-2009 Torch Mobile, Inc.
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 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 String result = String::createUninitialized(length, destination); 880 String result = String::createUninitialized(length, destination);
881 881
882 copyLCharsFromUCharSource(destination, source, length); 882 copyLCharsFromUCharSource(destination, source, length);
883 883
884 return result; 884 return result;
885 } 885 }
886 886
887 String String::make16BitFrom8BitSource(const LChar* source, size_t length) 887 String String::make16BitFrom8BitSource(const LChar* source, size_t length)
888 { 888 {
889 if (!length) 889 if (!length)
890 return emptyString(); 890 return emptyString(Force16BitEmpty);
891 891
892 UChar* destination; 892 UChar* destination;
893 String result = String::createUninitialized(length, destination); 893 String result = String::createUninitialized(length, destination);
894 894
895 StringImpl::copyChars(destination, source, length); 895 StringImpl::copyChars(destination, source, length);
896 896
897 return result; 897 return result;
898 } 898 }
899 899
900 String String::fromUTF8(const LChar* stringStart, size_t length) 900 String String::fromUTF8(const LChar* stringStart, size_t length)
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 // FIXME: This will return ok even when the string fits into a double but no t a float. 1219 // FIXME: This will return ok even when the string fits into a double but no t a float.
1220 return static_cast<float>(toDoubleType<UChar, AllowTrailingJunk>(data, lengt h, 0, parsedLength)); 1220 return static_cast<float>(toDoubleType<UChar, AllowTrailingJunk>(data, lengt h, 0, parsedLength));
1221 } 1221 }
1222 1222
1223 const String& emptyString() 1223 const String& emptyString()
1224 { 1224 {
1225 DEFINE_STATIC_LOCAL(String, emptyString, (StringImpl::empty())); 1225 DEFINE_STATIC_LOCAL(String, emptyString, (StringImpl::empty()));
1226 return emptyString; 1226 return emptyString;
1227 } 1227 }
1228 1228
1229 const String& emptyString(Force16Bit)
1230 {
1231 DEFINE_STATIC_LOCAL(String, emptyString, (StringImpl::empty(StringImpl::Forc e16BitEmpty)));
1232 return emptyString;
1233 }
1234
1229 } // namespace WTF 1235 } // namespace WTF
1230 1236
1231 #ifndef NDEBUG 1237 #ifndef NDEBUG
1232 // For use in the debugger 1238 // For use in the debugger
1233 String* string(const char*); 1239 String* string(const char*);
1234 Vector<char> asciiDebug(StringImpl* impl); 1240 Vector<char> asciiDebug(StringImpl* impl);
1235 Vector<char> asciiDebug(String& string); 1241 Vector<char> asciiDebug(String& string);
1236 1242
1237 void String::show() const 1243 void String::show() const
1238 { 1244 {
(...skipping 27 matching lines...) Expand all
1266 buffer.append('\0'); 1272 buffer.append('\0');
1267 return buffer; 1273 return buffer;
1268 } 1274 }
1269 1275
1270 Vector<char> asciiDebug(String& string) 1276 Vector<char> asciiDebug(String& string)
1271 { 1277 {
1272 return asciiDebug(string.impl()); 1278 return asciiDebug(string.impl());
1273 } 1279 }
1274 1280
1275 #endif 1281 #endif
OLDNEW
« Source/wtf/text/WTFString.h ('K') | « Source/wtf/text/WTFString.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698