mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
Modernize std::count
with ranges
This commit is contained in:
parent
ed5eb49d47
commit
c46060e298
@ -143,7 +143,7 @@ enum class FileLookupMode
|
|||||||
static SystemTimers::TimeBaseTick EstimateFileLookupTicks(const std::string& path,
|
static SystemTimers::TimeBaseTick EstimateFileLookupTicks(const std::string& path,
|
||||||
FileLookupMode mode)
|
FileLookupMode mode)
|
||||||
{
|
{
|
||||||
const size_t number_of_path_components = std::count(path.cbegin(), path.cend(), '/');
|
const size_t number_of_path_components = std::ranges::count(path, '/');
|
||||||
if (number_of_path_components == 0)
|
if (number_of_path_components == 0)
|
||||||
return 0_tbticks;
|
return 0_tbticks;
|
||||||
|
|
||||||
|
@ -467,7 +467,7 @@ ResultCode HostFileSystem::CreateFileOrDirectory(Uid uid, Gid gid, const std::st
|
|||||||
return ResultCode::Invalid;
|
return ResultCode::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_file && std::count(path.begin(), path.end(), '/') > int(MaxPathDepth))
|
if (!is_file && std::ranges::count(path, '/') > int(MaxPathDepth))
|
||||||
return ResultCode::TooManyPathComponents;
|
return ResultCode::TooManyPathComponents;
|
||||||
|
|
||||||
const auto split_path = SplitPathAndBasename(path);
|
const auto split_path = SplitPathAndBasename(path);
|
||||||
|
@ -121,7 +121,7 @@ TEST_F(FileSystemTest, CreateFile)
|
|||||||
|
|
||||||
const Result<std::vector<std::string>> tmp_files = m_fs->ReadDirectory(Uid{0}, Gid{0}, "/tmp");
|
const Result<std::vector<std::string>> tmp_files = m_fs->ReadDirectory(Uid{0}, Gid{0}, "/tmp");
|
||||||
ASSERT_TRUE(tmp_files.Succeeded());
|
ASSERT_TRUE(tmp_files.Succeeded());
|
||||||
EXPECT_EQ(std::count(tmp_files->begin(), tmp_files->end(), "f"), 1u);
|
EXPECT_EQ(std::ranges::count(*tmp_files, "f"), 1u);
|
||||||
|
|
||||||
// Test invalid paths
|
// Test invalid paths
|
||||||
// Unprintable characters
|
// Unprintable characters
|
||||||
|
Loading…
Reference in New Issue
Block a user