Tweaks `make_canonical_path` for better performance