[libcxx-commits] [PATCH] D98412: [libcxx] Avoid intermediate string objects for substrings in windows operator/=
Martin Storsjö via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Mar 11 09:35:38 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG49173ca4db21: [libcxx] Avoid intermediate string objects for substrings in windows operator/= (authored by mstorsjo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98412/new/
https://reviews.llvm.org/D98412
Files:
libcxx/include/filesystem
libcxx/test/std/input.output/filesystems/class.path/path.member/path.append.pass.cpp
Index: libcxx/test/std/input.output/filesystems/class.path/path.member/path.append.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/class.path/path.member/path.append.pass.cpp
+++ libcxx/test/std/input.output/filesystems/class.path/path.member/path.append.pass.cpp
@@ -175,6 +175,15 @@
}
assert(PathEq(LHS, E));
}
+ {
+ path LHS(L); PathReserve(LHS, ReserveSize);
+ path RHS(R);
+ {
+ DisableAllocationGuard g;
+ LHS /= RHS;
+ }
+ assert(PathEq(LHS, E));
+ }
// input iterator - For non-native char types, appends needs to copy the
// iterator range into a contiguous block of memory before it can perform the
// code_cvt conversions.
Index: libcxx/include/filesystem
===================================================================
--- libcxx/include/filesystem
+++ libcxx/include/filesystem
@@ -1026,12 +1026,12 @@
if (__p.has_root_directory()) {
path __root_name_str = root_name();
__pn_ = __root_name_str.native();
- __pn_ += __p.__pn_.substr(__p_root_name_size);
+ __pn_ += __string_view(__p.__pn_).substr(__p_root_name_size);
return *this;
}
if (has_filename() || (!has_root_directory() && is_absolute()))
__pn_ += preferred_separator;
- __pn_ += __p.__pn_.substr(__p_root_name_size);
+ __pn_ += __string_view(__p.__pn_).substr(__p_root_name_size);
return *this;
}
template <class _Source>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98412.329997.patch
Type: text/x-patch
Size: 1491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210311/732c7101/attachment.bin>
More information about the libcxx-commits
mailing list