Skip to content

Commit b95ba0e

Browse files
authored
Avoid calling size() in empty() member functions (#1836)
1 parent b29a701 commit b95ba0e

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

stl/inc/vector

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2798,7 +2798,7 @@ public:
27982798
}
27992799

28002800
_NODISCARD _CONSTEXPR20_CONTAINER bool empty() const noexcept {
2801-
return size() == 0;
2801+
return this->_Mysize == 0;
28022802
}
28032803

28042804
_NODISCARD _CONSTEXPR20_CONTAINER allocator_type get_allocator() const noexcept {

stl/inc/xstring

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4016,7 +4016,7 @@ public:
40164016
#endif // _HAS_CXX20
40174017

40184018
_NODISCARD _CONSTEXPR20_CONTAINER bool empty() const noexcept {
4019-
return size() == 0;
4019+
return _Mypair._Myval2._Mysize == 0;
40204020
}
40214021

40224022
_CONSTEXPR20_CONTAINER size_type copy(

stl/inc/xtree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ public:
12161216
}
12171217

12181218
_NODISCARD bool empty() const noexcept {
1219-
return size() == 0;
1219+
return _Get_scary()->_Mysize == 0;
12201220
}
12211221

12221222
_NODISCARD allocator_type get_allocator() const noexcept {

0 commit comments

Comments
 (0)