зеркало из https://github.com/microsoft/STL.git
<filesystem>: Avoid additional allocations in path::lexically_relative (#1915)
Co-authored-by: Nicole Mazzuca <mazzucan@outlook.com>
This commit is contained in:
Родитель
1ea95df4d4
Коммит
e093bb13da
|
@ -1667,11 +1667,21 @@ namespace filesystem {
|
|||
return _Val;
|
||||
}
|
||||
|
||||
_NODISCARD inline bool _Starts_with_root_name(const wchar_t* const _First, const wchar_t* const _Last) {
|
||||
return _Find_root_name_end(_First, _Last) != _First;
|
||||
}
|
||||
|
||||
_NODISCARD inline bool _Relative_path_contains_root_name(const path& _Path) {
|
||||
for (const auto& _File_name : _Path.relative_path()) {
|
||||
if (!_Parse_root_name(_File_name.native()).empty()) {
|
||||
const auto& _Native = _Path.native();
|
||||
auto _First = _Native.data();
|
||||
const auto _Last = _First + _Native.size();
|
||||
_First = _Find_relative_path(_First, _Last);
|
||||
while (_First != _Last) {
|
||||
const auto _Next = _STD find_if(_First, _Last, _Is_slash);
|
||||
if (_Starts_with_root_name(_First, _Next)) {
|
||||
return true;
|
||||
}
|
||||
_First = _STD find_if_not(_Next, _Last, _Is_slash);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче