src/platform/path.cpp:113 calls expand() and then canonicalises the result:
try {
const auto expanded = expand();
if (expanded) {
return path { std::filesystem::canonical(expanded.value()._path) };
}
...
} catch (const std::filesystem::filesystem_error& e) {
return std::unexpected(e);
}
For a path beginning with ~, expand() already canonicalises, so canonical() runs a second time on an already-canonical path. It is idempotent, so the result is right, but it costs another round of stat/readlink.
The catch block is also dead for those paths now: since expand() converts its own filesystem_error into std::unexpected, nothing throws out of the try for a ~ path. It still catches for non-~ paths, where expand() returns the path unchanged and line 115 does the only canonicalisation.
Narrowing the try to the canonical() call would make it symmetric with expand(), which covers only the call that can throw.
src/platform/path.cpp:113callsexpand()and then canonicalises the result:For a path beginning with
~,expand()already canonicalises, socanonical()runs a second time on an already-canonical path. It is idempotent, so the result is right, but it costs another round ofstat/readlink.The
catchblock is also dead for those paths now: sinceexpand()converts its ownfilesystem_errorintostd::unexpected, nothing throws out of thetryfor a~path. It still catches for non-~paths, whereexpand()returns the path unchanged and line 115 does the only canonicalisation.Narrowing the
tryto thecanonical()call would make it symmetric withexpand(), which covers only the call that can throw.