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

Side by Side Diff: third_party/WebKit/Source/platform/SharedBufferChunkReader.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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 112
113 String SharedBufferChunkReader::nextChunkAsUTF8StringWithLatin1Fallback( 113 String SharedBufferChunkReader::nextChunkAsUTF8StringWithLatin1Fallback(
114 bool includeSeparator) { 114 bool includeSeparator) {
115 Vector<char> data; 115 Vector<char> data;
116 if (!nextChunk(data, includeSeparator)) 116 if (!nextChunk(data, includeSeparator))
117 return String(); 117 return String();
118 118
119 return data.size() 119 return data.size()
120 ? String::fromUTF8WithLatin1Fallback(data.data(), data.size()) 120 ? String::fromUTF8WithLatin1Fallback(data.data(), data.size())
121 : emptyString(); 121 : emptyString;
122 } 122 }
123 123
124 size_t SharedBufferChunkReader::peek(Vector<char>& data, size_t requestedSize) { 124 size_t SharedBufferChunkReader::peek(Vector<char>& data, size_t requestedSize) {
125 data.clear(); 125 data.clear();
126 if (requestedSize <= m_segmentLength - m_segmentIndex) { 126 if (requestedSize <= m_segmentLength - m_segmentIndex) {
127 data.append(m_segment + m_segmentIndex, requestedSize); 127 data.append(m_segment + m_segmentIndex, requestedSize);
128 return requestedSize; 128 return requestedSize;
129 } 129 }
130 130
131 size_t readBytesCount = m_segmentLength - m_segmentIndex; 131 size_t readBytesCount = m_segmentLength - m_segmentIndex;
132 data.append(m_segment + m_segmentIndex, readBytesCount); 132 data.append(m_segment + m_segmentIndex, readBytesCount);
133 133
134 size_t bufferPosition = m_bufferPosition + m_segmentLength; 134 size_t bufferPosition = m_bufferPosition + m_segmentLength;
135 const char* segment = 0; 135 const char* segment = 0;
136 while (size_t segmentLength = 136 while (size_t segmentLength =
137 m_buffer->getSomeData(segment, bufferPosition)) { 137 m_buffer->getSomeData(segment, bufferPosition)) {
138 if (requestedSize <= readBytesCount + segmentLength) { 138 if (requestedSize <= readBytesCount + segmentLength) {
139 data.append(segment, requestedSize - readBytesCount); 139 data.append(segment, requestedSize - readBytesCount);
140 readBytesCount += (requestedSize - readBytesCount); 140 readBytesCount += (requestedSize - readBytesCount);
141 break; 141 break;
142 } 142 }
143 data.append(segment, segmentLength); 143 data.append(segment, segmentLength);
144 readBytesCount += segmentLength; 144 readBytesCount += segmentLength;
145 bufferPosition += segmentLength; 145 bufferPosition += segmentLength;
146 } 146 }
147 return readBytesCount; 147 return readBytesCount;
148 } 148 }
149 149
150 } // namespace blink 150 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698