[PATCH] Micro-optimization to avoid creating temporary path

Jonathan Wakely jwakely@redhat.com
Tue Dec 18 16:38:00 GMT 2018


On 18/12/18 15:52 +0000, Jonathan Wakely wrote:
>Now that path::operator/=(basic_string_view<value_type>) works directly
>from the string argument, instead of constructing a temporary path from
>the string, it's potentially more efficient to do 'path(x) /= s' instead
>of 'x / s'. This changes the only relevant place in the library.
>
>	* src/filesystem/std-dir.cc (filesystem::_Dir::advance): Append
>	string to lvalue to avoid creating temporary path.

This is only an optimization if it doesn't introduce a new copy! Fixed
by the attached patch.

Tested x86_64-linux, committed to trunk.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 797 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20181218/ce48c8d1/attachment.bin>


More information about the Libstdc++ mailing list