1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-23 02:42:09 +00:00

fs.mitm: Optimize out remaining O(n^2) op. BotW is very fast.

This commit is contained in:
Michael Scire 2018-06-28 23:24:08 -06:00
parent 90226ec438
commit 4c920dfe92
2 changed files with 7 additions and 10 deletions

View file

@ -273,12 +273,10 @@ void RomFSBuildContext::Build(std::vector<RomFSSourceInfo> *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<RomFSSourceInfo> *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;
}
}
}

View file

@ -153,6 +153,7 @@ struct RomFSBuildDirectoryContext {
RomFSBuildDirectoryContext *child = NULL;
RomFSBuildDirectoryContext *sibling = NULL;
RomFSBuildFileContext *file = NULL;
void *tail;
};
struct RomFSBuildFileContext {