Skip to content

Commit

Permalink
smells
Browse files Browse the repository at this point in the history
  • Loading branch information
frs69wq committed May 24, 2024
1 parent 08ba41c commit a378e9b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions include/fsmod/PathUtil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ namespace simgrid::fsmod {

class XBT_PUBLIC PathUtil {
public:
static std::string simplify_path_string(const std::string &path);
static std::string simplify_path_string(const std::string& path);
static void remove_trailing_slashes(std::string &path);
static std::pair<std::string, std::string> split_path(const std::string &path);
static bool is_at_mount_point(const std::string &simplified_absolute_path, const std::string &mount_point);
static std::string path_at_mount_point(const std::string &simplified_absolute_path, const std::string &mount_point);
static std::pair<std::string, std::string> split_path(std::string_view path);
static bool is_at_mount_point(std::string_view simplified_absolute_path, std::string_view mount_point);
static std::string path_at_mount_point(const std::string& simplified_absolute_path, std::string_view mount_point);
};

/** \endcond */
Expand Down
8 changes: 4 additions & 4 deletions src/PartitionFIFOCaching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ namespace simgrid::fsmod {
sg_size_t space_that_can_be_created = 0.0;
std::vector<unsigned long> files_to_remove_to_create_space;

for (auto const &victim: priority_list_) {
for (auto const& [victim, victim_metadata]: priority_list_) {
// Never evict an open file
if (victim.second->file_refcount_ > 0) {
if (victim_metadata->file_refcount_ > 0) {
continue;
}
// Found a victim
files_to_remove_to_create_space.push_back(victim.first);
space_that_can_be_created += victim.second->current_size_;
files_to_remove_to_create_space.push_back(victim);
space_that_can_be_created += victim_metadata->current_size_;
if (space_that_can_be_created >= num_bytes) {
break;
}
Expand Down
8 changes: 4 additions & 4 deletions src/PathUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace simgrid::fsmod {
* @return A new path string that has been sanitized
* (i.e., remove redundant slashes, resolved ".."'s and "."'s)
*/
std::string PathUtil::simplify_path_string(const std::string &path_string) {
std::string PathUtil::simplify_path_string(const std::string& path_string) {
// Prepend with "/" as that's always the working directory
auto lexically_normal = std::string(std::filesystem::path("/"+path_string).lexically_normal());
PathUtil::remove_trailing_slashes(lexically_normal);
Expand All @@ -36,7 +36,7 @@ namespace simgrid::fsmod {
* @param path_string: a simplified path string
* @return a <prefix , suffix> pair, where either one of them could be empty
*/
std::pair<std::string, std::string> PathUtil::split_path(const std::string &path) {
std::pair<std::string, std::string> PathUtil::split_path(std::string_view path) {
std::string dir;
std::string file;

Expand All @@ -57,7 +57,7 @@ namespace simgrid::fsmod {
* @param mount_point: a mount point
* @return True if mount_point is a prefix of simplified_absolute_path, false otherwise
*/
bool PathUtil::is_at_mount_point(const std::string &simplified_absolute_path, const std::string &mount_point) {
bool PathUtil::is_at_mount_point(std::string_view simplified_absolute_path, std::string_view mount_point) {
return simplified_absolute_path.rfind(mount_point, 0) == 0;
}

Expand All @@ -68,7 +68,7 @@ namespace simgrid::fsmod {
* @return The path at the mount point
* @throws std::logic_error If the path is not at that mount point
*/
std::string PathUtil::path_at_mount_point(const std::string &simplified_absolute_path, const std::string &mount_point) {
std::string PathUtil::path_at_mount_point(const std::string& simplified_absolute_path, std::string_view mount_point) {
if (simplified_absolute_path.rfind(mount_point, 0) != 0) {
throw std::logic_error("Path not found at mount point");
} else {
Expand Down

0 comments on commit a378e9b

Please sign in to comment.