VirtualBox

Changeset 55947 in vbox for trunk/include/iprt


Ignore:
Timestamp:
May 19, 2015 11:41:34 PM (10 years ago)
Author:
vboxsync
Message:

iprt/cpp/list.h: Eliminated RT_UNLIKELY.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/cpp/list.h

    r49052 r55947  
    458458    {
    459459        /* Prevent self assignment */
    460         if (RT_UNLIKELY(this == &other))
    461             return *this;
    462 
    463         other.m_guard.enterRead();
    464         m_guard.enterWrite();
    465 
    466         /* Delete all items. */
    467         RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_cElements);
    468 
    469         /* Need we to realloc memory. */
    470         if (other.m_cElements != m_cCapacity)
    471             resizeArrayNoErase(other.m_cElements);
    472         m_cElements = other.m_cElements;
    473 
    474         /* Copy new items. */
    475         RTCListHelper<T, ITYPE>::copyTo(m_pArray, other.m_pArray, 0, other.m_cElements);
    476 
    477         m_guard.leaveWrite();
    478         other.m_guard.leaveRead();
     460        if (RT_LIKELY(this != &other))
     461        {
     462
     463            other.m_guard.enterRead();
     464            m_guard.enterWrite();
     465
     466            /* Delete all items. */
     467            RTCListHelper<T, ITYPE>::eraseRange(m_pArray, 0, m_cElements);
     468
     469            /* Need we to realloc memory. */
     470            if (other.m_cElements != m_cCapacity)
     471                resizeArrayNoErase(other.m_cElements);
     472            m_cElements = other.m_cElements;
     473
     474            /* Copy new items. */
     475            RTCListHelper<T, ITYPE>::copyTo(m_pArray, other.m_pArray, 0, other.m_cElements);
     476
     477            m_guard.leaveWrite();
     478            other.m_guard.leaveRead();
     479        }
    479480        return *this;
    480481    }
     
    635636    {
    636637        m_guard.enterRead();
    637         if (RT_UNLIKELY(i >= m_cElements))
    638         {
     638        if (RT_LIKELY(i < m_cElements))
     639        {
     640            T res = RTCListHelper<T, ITYPE>::at(m_pArray, i);
    639641            m_guard.leaveRead();
    640             return T();
    641         }
    642         T res = RTCListHelper<T, ITYPE>::at(m_pArray, i);
    643         m_guard.leaveRead();
    644         return res;
     642            return res;
     643        }
     644        m_guard.leaveRead();
     645        return T();
    645646    }
    646647
     
    655656    {
    656657        m_guard.enterRead();
    657         if (RT_UNLIKELY(i >= m_cElements))
    658         {
     658        if (RT_LIKELY(i < m_cElements))
     659        {
     660            T res = RTCListHelper<T, ITYPE>::at(m_pArray, i);
    659661            m_guard.leaveRead();
    660             return defaultVal;
    661         }
    662         T res = RTCListHelper<T, ITYPE>::at(m_pArray, i);
    663         m_guard.leaveRead();
    664         return res;
     662            return res;
     663        }
     664        m_guard.leaveRead();
     665        return defaultVal;
    665666    }
    666667
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette