Chromium Code Reviews| Index: Source/platform/image-decoders/FastSharedBufferReader.cpp |
| diff --git a/Source/platform/image-decoders/FastSharedBufferReader.cpp b/Source/platform/image-decoders/FastSharedBufferReader.cpp |
| index 4475960fdcb4a12dab70112a482d779630b558e4..e02a70551c706556f5f4b1787cc1f8eae29248bc 100644 |
| --- a/Source/platform/image-decoders/FastSharedBufferReader.cpp |
| +++ b/Source/platform/image-decoders/FastSharedBufferReader.cpp |
| @@ -56,17 +56,25 @@ const char* FastSharedBufferReader::getConsecutiveData(size_t dataPosition, size |
| if (length <= m_segmentLength) |
| return m_segment; |
| - for (char* tempBuffer = buffer; length;) { |
| + char* dest = buffer; |
|
Peter Kasting
2015/03/20 20:29:33
Nit: Convert the while to a for so you can move th
|
| + while (true) { |
| size_t copy = std::min(length, m_segmentLength); |
| - memcpy(tempBuffer, m_segment, copy); |
| + memcpy(dest, m_segment, copy); |
| m_dataPosition += copy; |
|
kbalazs
2015/03/25 19:38:10
I also introduced an error. m_dataPosition should
|
| length -= copy; |
| - tempBuffer += copy; |
| + if (!length) { |
| + // Done. |
| + return buffer; |
| + } |
| + // Continue reading the next segment. |
| + dest += copy; |
| m_segmentLength = m_data->getSomeData(m_segment, m_dataPosition); |
| ASSERT(m_segmentLength); |
| } |
| - return buffer; |
| + |
| + ASSERT_NOT_REACHED(); |
|
Peter Kasting
2015/03/20 01:10:42
I think these two lines will trigger MSVC warning
kbalazs
2015/03/20 20:20:42
Acknowledged.
|
| + return 0; |
| } |
| size_t FastSharedBufferReader::getSomeData(const char*& someData, size_t dataPosition) |