We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
std::filesystem::path::lexically_relative
1 parent 38c17f3 commit bb56342Copy full SHA for bb56342
libcxx/src/filesystem/path.cpp
@@ -292,7 +292,9 @@ path path::lexically_relative(const path& base) const {
292
// return a path constructed with 'n' dot-dot elements, followed by the
293
// elements of '*this' after the mismatch.
294
path Result;
295
- // FIXME: Reserve enough room in Result that it won't have to re-allocate.
+ constexpr size_t ElemSize = 2; // ".."
296
+ constexpr size_t SeparatorSize = 1; // separator is always a single char
297
+ Result.__reserve(ElemCount * (ElemSize + SeparatorSize) + SeparatorSize + PP.Path.size());
298
while (ElemCount--)
299
Result /= PATHSTR("..");
300
for (; PP; ++PP)
0 commit comments