Changeset 55947 in vbox for trunk/include/iprt
- Timestamp:
- May 19, 2015 11:41:34 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpp/list.h
r49052 r55947 458 458 { 459 459 /* 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 } 479 480 return *this; 480 481 } … … 635 636 { 636 637 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); 639 641 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(); 645 646 } 646 647 … … 655 656 { 656 657 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); 659 661 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; 665 666 } 666 667
Note:
See TracChangeset
for help on using the changeset viewer.