Skip to content

Commit

Permalink
Simplify the backwards loop in char_traits::move (#2055)
Browse files Browse the repository at this point in the history
  • Loading branch information
AZero13 authored Jul 20, 2021
1 parent 8b7ea0a commit bd7adb4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions stl/inc/xstring
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct _Char_traits { // properties of a string or stream element
#if _HAS_CXX20
if (_STD is_constant_evaluated()) {
// pre: [_First1, _First1 + _Count) and [_First2, _First2 + _Count) do not overlap; see LWG-3085
for (size_t _Idx = 0; _Idx < _Count; ++_Idx) {
for (size_t _Idx = 0; _Idx != _Count; ++_Idx) {
_First1[_Idx] = _First2[_Idx];
}

Expand Down Expand Up @@ -106,12 +106,12 @@ struct _Char_traits { // properties of a string or stream element
}

if (_Loop_forward) {
for (size_t _Idx = 0; _Idx < _Count; ++_Idx) {
for (size_t _Idx = 0; _Idx != _Count; ++_Idx) {
_First1[_Idx] = _First2[_Idx];
}
} else {
for (size_t _Idx = 0; _Idx < _Count; ++_Idx) {
_First1[_Count - 1 - _Idx] = _First2[_Count - 1 - _Idx];
for (size_t _Idx = _Count; _Idx != 0; --_Idx) {
_First1[_Idx - 1] = _First2[_Idx - 1];
}
}

Expand Down

0 comments on commit bd7adb4

Please sign in to comment.