diff --git a/stratosphere/fs_mitm/source/fsmitm_romfsbuild.cpp b/stratosphere/fs_mitm/source/fsmitm_romfsbuild.cpp index e493994e8..3698f57f9 100644 --- a/stratosphere/fs_mitm/source/fsmitm_romfsbuild.cpp +++ b/stratosphere/fs_mitm/source/fsmitm_romfsbuild.cpp @@ -273,12 +273,10 @@ void RomFSBuildContext::Build(std::vector *out_infos) { /* Assign deferred parent/sibling ownership. */ if (cur_file->parent->file == NULL) { cur_file->parent->file = cur_file; + cur_file->parent->tail = cur_file; } else { - RomFSBuildFileContext *temp = cur_file->parent->file; - while (temp->sibling != NULL) { - temp = temp->sibling; - } - temp->sibling = cur_file; + ((RomFSBuildFileContext *)cur_file->parent->tail)->sibling = cur_file; + cur_file->parent->tail = cur_file; } prev_file = cur_file; @@ -295,12 +293,10 @@ void RomFSBuildContext::Build(std::vector *out_infos) { if (cur_dir != this->root) { if (cur_dir->parent->child == NULL) { cur_dir->parent->child = cur_dir; + cur_dir->parent->tail = cur_dir; } else { - RomFSBuildDirectoryContext *temp = cur_dir->parent->child; - while (temp->sibling != NULL) { - temp = temp->sibling; - } - temp->sibling = cur_dir; + ((RomFSBuildDirectoryContext *)cur_dir->parent->tail)->sibling = cur_dir; + cur_dir->parent->tail = cur_dir; } } } diff --git a/stratosphere/fs_mitm/source/fsmitm_romfsbuild.hpp b/stratosphere/fs_mitm/source/fsmitm_romfsbuild.hpp index 004bf5426..3646e9769 100644 --- a/stratosphere/fs_mitm/source/fsmitm_romfsbuild.hpp +++ b/stratosphere/fs_mitm/source/fsmitm_romfsbuild.hpp @@ -153,6 +153,7 @@ struct RomFSBuildDirectoryContext { RomFSBuildDirectoryContext *child = NULL; RomFSBuildDirectoryContext *sibling = NULL; RomFSBuildFileContext *file = NULL; + void *tail; }; struct RomFSBuildFileContext {