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

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

Issue 2668903003: Replace WTF::emptyString{16Bit}() with a static global (Closed)
Patch Set: Replace WTF::emptyString{16Bit}() with a static global Created 3 years, 10 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 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 registrar("US-ASCII", newStreamingTextDecoderWindowsLatin1, 0); 105 registrar("US-ASCII", newStreamingTextDecoderWindowsLatin1, 0);
106 } 106 }
107 107
108 String TextCodecLatin1::decode(const char* bytes, 108 String TextCodecLatin1::decode(const char* bytes,
109 size_t length, 109 size_t length,
110 FlushBehavior, 110 FlushBehavior,
111 bool, 111 bool,
112 bool&) { 112 bool&) {
113 LChar* characters; 113 LChar* characters;
114 if (!length) 114 if (!length)
115 return emptyString(); 115 return emptyString;
116 String result = String::createUninitialized(length, characters); 116 String result = String::createUninitialized(length, characters);
117 117
118 const uint8_t* source = reinterpret_cast<const uint8_t*>(bytes); 118 const uint8_t* source = reinterpret_cast<const uint8_t*>(bytes);
119 const uint8_t* end = reinterpret_cast<const uint8_t*>(bytes + length); 119 const uint8_t* end = reinterpret_cast<const uint8_t*>(bytes + length);
120 const uint8_t* alignedEnd = alignToMachineWord(end); 120 const uint8_t* alignedEnd = alignToMachineWord(end);
121 LChar* destination = characters; 121 LChar* destination = characters;
122 122
123 while (source < end) { 123 while (source < end) {
124 if (isASCII(*source)) { 124 if (isASCII(*source)) {
125 // Fast path for ASCII. Most Latin-1 text will be ASCII. 125 // Fast path for ASCII. Most Latin-1 text will be ASCII.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 return encodeCommon(characters, length, handling); 284 return encodeCommon(characters, length, handling);
285 } 285 }
286 286
287 CString TextCodecLatin1::encode(const LChar* characters, 287 CString TextCodecLatin1::encode(const LChar* characters,
288 size_t length, 288 size_t length,
289 UnencodableHandling handling) { 289 UnencodableHandling handling) {
290 return encodeCommon(characters, length, handling); 290 return encodeCommon(characters, length, handling);
291 } 291 }
292 292
293 } // namespace WTF 293 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringViewTest.cpp ('k') | third_party/WebKit/Source/wtf/text/WTFString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698