diff options
| author | Marcel Braun <marcel.braun@ost.ch> | 2026-05-04 20:31:58 +0200 |
|---|---|---|
| committer | Lukas Oesch <lukasoesch20@gmail.com> | 2026-05-05 14:38:52 +0200 |
| commit | d1e64340abb960c579651635d580660c12f94e6e (patch) | |
| tree | 31199de40c1cc35bcca83b703715b677c94cb219 /kernel | |
| parent | d90d6bb4b4820df6cb4b0747439293bb85b8cbec (diff) | |
| download | kernel-d1e64340abb960c579651635d580660c12f94e6e.tar.xz kernel-d1e64340abb960c579651635d580660c12f94e6e.zip | |
Refactor path resolution, use vector and while instead of iterator and for-loop
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/src/filesystem/vfs.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/kernel/src/filesystem/vfs.cpp b/kernel/src/filesystem/vfs.cpp index 8f48820..c9939fa 100644 --- a/kernel/src/filesystem/vfs.cpp +++ b/kernel/src/filesystem/vfs.cpp @@ -12,7 +12,9 @@ #include <kstd/memory> #include <kstd/string> +#include <kstd/vector> +#include <algorithm> #include <optional> #include <ranges> #include <string_view> @@ -159,10 +161,13 @@ namespace kernel::filesystem auto current_dentry = current_mount->root_dentry(); auto path_parts = kernel::filesystem::path::split(path); + kstd::vector path_parts_vector(path_parts.begin(), path_parts.end()); + std::ranges::reverse(path_parts_vector); - for (auto it = path_parts.begin(); it != path_parts.end(); ++it) + while (!path_parts_vector.empty()) { - std::string_view part_view{*it}; + std::string_view part_view{path_parts_vector.back()}; + path_parts_vector.pop_back(); if (part_view == ".") { |
