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

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
« no previous file with comments | « 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(false);
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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 // FIXME: This will return ok even when the string fits into a double but no t a float. 1213 // FIXME: This will return ok even when the string fits into a double but no t a float.
1214 return static_cast<float>(toDoubleType<LChar, AllowTrailingJunk>(data, lengt h, 0, parsedLength)); 1214 return static_cast<float>(toDoubleType<LChar, AllowTrailingJunk>(data, lengt h, 0, parsedLength));
1215 } 1215 }
1216 1216
1217 float charactersToFloat(const UChar* data, size_t length, size_t& parsedLength) 1217 float charactersToFloat(const UChar* data, size_t length, size_t& parsedLength)
1218 { 1218 {
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(bool is8Bit)
1224 { 1224 {
1225 DEFINE_STATIC_LOCAL(String, emptyString, (StringImpl::empty())); 1225 DEFINE_STATIC_LOCAL(String, empty8BitString, (StringImpl::empty()));
1226 return emptyString; 1226 DEFINE_STATIC_LOCAL(String, empty16BitString, (StringImpl::empty(false)));
1227 return is8Bit ? empty8BitString : empty16BitString;
Mikhail 2014/09/22 10:26:18 I'm afraid this might affect the performance, what
1227 } 1228 }
1228 1229
1229 } // namespace WTF 1230 } // namespace WTF
1230 1231
1231 #ifndef NDEBUG 1232 #ifndef NDEBUG
1232 // For use in the debugger 1233 // For use in the debugger
1233 String* string(const char*); 1234 String* string(const char*);
1234 Vector<char> asciiDebug(StringImpl* impl); 1235 Vector<char> asciiDebug(StringImpl* impl);
1235 Vector<char> asciiDebug(String& string); 1236 Vector<char> asciiDebug(String& string);
1236 1237
(...skipping 29 matching lines...) Expand all
1266 buffer.append('\0'); 1267 buffer.append('\0');
1267 return buffer; 1268 return buffer;
1268 } 1269 }
1269 1270
1270 Vector<char> asciiDebug(String& string) 1271 Vector<char> asciiDebug(String& string)
1271 { 1272 {
1272 return asciiDebug(string.impl()); 1273 return asciiDebug(string.impl());
1273 } 1274 }
1274 1275
1275 #endif 1276 #endif
OLDNEW
« no previous file with comments | « Source/wtf/text/WTFString.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698