Changeset 172735 in webkit


Ignore:
Timestamp:
Aug 18, 2014 4:22:59 PM (10 years ago)
Author:
psolanki@apple.com
Message:

Use modern for loop instead of iterators in SharedBufferCF.cpp
https://bugs.webkit.org/show_bug.cgi?id=136000

Reviewed by Andreas Kling.

  • platform/cf/SharedBufferCF.cpp:

(WebCore::SharedBuffer::copyBufferAndClear):
(WebCore::SharedBuffer::copySomeDataFromDataArray):
(WebCore::SharedBuffer::maybeAppendDataArray): Use auto& instead of auto for less RetainPtr/refcount churn.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r172730 r172735  
     12014-08-18  Pratik Solanki  <psolanki@apple.com>
     2
     3        Use modern for loop instead of iterators in SharedBufferCF.cpp
     4        https://bugs.webkit.org/show_bug.cgi?id=136000
     5
     6        Reviewed by Andreas Kling.
     7
     8        * platform/cf/SharedBufferCF.cpp:
     9        (WebCore::SharedBuffer::copyBufferAndClear):
     10        (WebCore::SharedBuffer::copySomeDataFromDataArray):
     11        (WebCore::SharedBuffer::maybeAppendDataArray): Use auto& instead of auto for less RetainPtr/refcount churn.
     12
    1132014-08-18  Antti Koivisto  <antti@apple.com>
    214
  • trunk/Source/WebCore/platform/cf/SharedBufferCF.cpp

    r171526 r172735  
    158158
    159159    CFIndex bytesLeft = bytesToCopy;
    160     Vector<RetainPtr<CFDataRef>>::const_iterator end = m_dataArray.end();
    161     for (Vector<RetainPtr<CFDataRef>>::const_iterator it = m_dataArray.begin(); it != end; ++it) {
    162         CFIndex dataLen = CFDataGetLength(it->get());
     160    for (auto& cfData : m_dataArray) {
     161        CFIndex dataLen = CFDataGetLength(cfData.get());
    163162        ASSERT(bytesLeft >= dataLen);
    164         memcpy(destination, CFDataGetBytePtr(it->get()), dataLen);
     163        memcpy(destination, CFDataGetBytePtr(cfData.get()), dataLen);
    165164        destination += dataLen;
    166165        bytesLeft -= dataLen;
     
    171170unsigned SharedBuffer::copySomeDataFromDataArray(const char*& someData, unsigned position) const
    172171{
    173     Vector<RetainPtr<CFDataRef>>::const_iterator end = m_dataArray.end();
    174172    unsigned totalOffset = 0;
    175     for (Vector<RetainPtr<CFDataRef>>::const_iterator it = m_dataArray.begin(); it != end; ++it) {
    176         unsigned dataLen = static_cast<unsigned>(CFDataGetLength(it->get()));
     173    for (auto& cfData : m_dataArray) {
     174        unsigned dataLen = static_cast<unsigned>(CFDataGetLength(cfData.get()));
    177175        ASSERT(totalOffset <= position);
    178176        unsigned localOffset = position - totalOffset;
    179177        if (localOffset < dataLen) {
    180             someData = reinterpret_cast<const char *>(CFDataGetBytePtr(it->get())) + localOffset;
     178            someData = reinterpret_cast<const char *>(CFDataGetBytePtr(cfData.get())) + localOffset;
    181179            return dataLen - localOffset;
    182180        }
     
    206204    unsigned originalSize = size();
    207205#endif
    208     for (auto cfData : data->m_dataArray)
     206    for (auto& cfData : data->m_dataArray)
    209207        append(cfData.get());
    210208    ASSERT(size() == originalSize + data->size());
Note: See TracChangeset for help on using the changeset viewer.