SystemTools: Refactor CollapseFullPath to call getcwd only when needed
Many calls to the one-argument CollapseFullPath
variant already have an absolute path and just need to collapse it. Avoid calling getcwd
if the result is not needed because it can be an expensive syscall.
Also drop the GetCurrentWorkingDirectory
argument and never call CollapseFullPath
inside it. The result of getcwd
is always an absolute canonical path and does not need to be collapsed.