Skip to content

Commit 5f91649

Browse files
Optimize std::__tree::__assign_multi to insert the provided range at the end of the tree every time (llvm#131030)
This improves performance for the copy-assignment operators of associative containers such as `std::map`. This optimization already exists in other places in the codebase, and seems to have been missed here.
1 parent f427890 commit 5f91649

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libcxx/include/__tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,8 +1411,9 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _
14111411
__cache.__advance();
14121412
}
14131413
}
1414+
const_iterator __e = end();
14141415
for (; __first != __last; ++__first)
1415-
__insert_multi(_NodeTypes::__get_value(*__first));
1416+
__insert_multi(__e, _NodeTypes::__get_value(*__first));
14161417
}
14171418

14181419
template <class _Tp, class _Compare, class _Allocator>

0 commit comments

Comments
 (0)