[libcxx-commits] [PATCH] D82111: Optimize 'construct at end' loops in vector
Martijn Vels via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jun 18 11:27:34 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd96aac435423: Optimize 'construct at end' loops in vector (authored by mvels).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82111/new/
https://reviews.llvm.org/D82111
Files:
libcxx/include/vector
Index: libcxx/include/vector
===================================================================
--- libcxx/include/vector
+++ libcxx/include/vector
@@ -1043,8 +1043,9 @@
vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
{
_ConstructTransaction __tx(*this, __n);
- for (; __tx.__pos_ != __tx.__new_end_; ++__tx.__pos_) {
- __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_));
+ const_pointer __new_end = __tx.__new_end_;
+ for (pointer __pos = __tx.__pos_; __pos != __new_end; ++__pos, __tx.__pos_ = __pos) {
+ __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__pos));
}
}
@@ -1060,8 +1061,9 @@
vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
{
_ConstructTransaction __tx(*this, __n);
- for (; __tx.__pos_ != __tx.__new_end_; ++__tx.__pos_) {
- __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_), __x);
+ const_pointer __new_end = __tx.__new_end_;
+ for (pointer __pos = __tx.__pos_; __pos != __new_end; ++__pos, __tx.__pos_ = __pos) {
+ __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__pos), __x);
}
}
@@ -1753,9 +1755,10 @@
{
pointer __i = __from_s + __n;
_ConstructTransaction __tx(*this, __from_e - __i);
- for (; __i < __from_e; ++__i, ++__tx.__pos_) {
+ for (pointer __pos = __tx.__pos_; __i < __from_e;
+ ++__i, ++__pos, __tx.__pos_ = __pos) {
__alloc_traits::construct(this->__alloc(),
- _VSTD::__to_address(__tx.__pos_),
+ _VSTD::__to_address(__pos),
_VSTD::move(*__i));
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82111.271792.patch
Type: text/x-patch
Size: 1748 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200618/3027f5d9/attachment-0001.bin>
More information about the libcxx-commits
mailing list