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

Side by Side Diff: Source/platform/SharedBuffer.cpp

Issue 972283002: Remove reserveCapacity call from SharedBuffer::mergeSegmentsIntoBuffer(). (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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 | « no previous file | 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 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 } 305 }
306 ASSERT(position == clone->size()); 306 ASSERT(position == clone->size());
307 } 307 }
308 return clone.release(); 308 return clone.release();
309 } 309 }
310 310
311 void SharedBuffer::mergeSegmentsIntoBuffer() const 311 void SharedBuffer::mergeSegmentsIntoBuffer() const
312 { 312 {
313 unsigned bufferSize = m_buffer.size(); 313 unsigned bufferSize = m_buffer.size();
314 if (m_size > bufferSize) { 314 if (m_size > bufferSize) {
315 m_buffer.reserveCapacity(m_size);
316 unsigned bytesLeft = m_size - bufferSize; 315 unsigned bytesLeft = m_size - bufferSize;
317 for (unsigned i = 0; i < m_segments.size(); ++i) { 316 for (unsigned i = 0; i < m_segments.size(); ++i) {
318 unsigned bytesToCopy = std::min(bytesLeft, segmentSize); 317 unsigned bytesToCopy = std::min(bytesLeft, segmentSize);
319 m_buffer.append(m_segments[i], bytesToCopy); 318 m_buffer.append(m_segments[i], bytesToCopy);
320 bytesLeft -= bytesToCopy; 319 bytesLeft -= bytesToCopy;
321 freeSegment(m_segments[i]); 320 freeSegment(m_segments[i]);
322 } 321 }
323 m_segments.clear(); 322 m_segments.clear();
324 } 323 }
325 } 324 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 mergeSegmentsIntoBuffer(); 406 mergeSegmentsIntoBuffer();
408 m_buffer.unlock(); 407 m_buffer.unlock();
409 } 408 }
410 409
411 bool SharedBuffer::isLocked() const 410 bool SharedBuffer::isLocked() const
412 { 411 {
413 return m_buffer.isLocked(); 412 return m_buffer.isLocked();
414 } 413 }
415 414
416 } // namespace blink 415 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698