Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor how file cache entries are stored #89301

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions editor/editor_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,24 +1333,28 @@ void EditorFileSystem::_save_filesystem_cache(EditorFileSystemDirectory *p_dir,
p_file->store_line("::" + p_dir->get_path() + "::" + String::num(p_dir->modified_time));

for (int i = 0; i < p_dir->files.size(); i++) {
if (!p_dir->files[i]->import_group_file.is_empty()) {
group_file_cache.insert(p_dir->files[i]->import_group_file);
const EditorFileSystemDirectory::FileInfo *file_info = p_dir->files[i];
if (!file_info->import_group_file.is_empty()) {
group_file_cache.insert(file_info->import_group_file);
}

String type = p_dir->files[i]->type;
if (p_dir->files[i]->resource_script_class) {
type += "/" + String(p_dir->files[i]->resource_script_class);
}
String s = p_dir->files[i]->file + "::" + type + "::" + itos(p_dir->files[i]->uid) + "::" + itos(p_dir->files[i]->modified_time) + "::" + itos(p_dir->files[i]->import_modified_time) + "::" + itos(p_dir->files[i]->import_valid) + "::" + p_dir->files[i]->import_group_file + "::" + p_dir->files[i]->script_class_name + "<>" + p_dir->files[i]->script_class_extends + "<>" + p_dir->files[i]->script_class_icon_path;
s += "::";
for (int j = 0; j < p_dir->files[i]->deps.size(); j++) {
if (j > 0) {
s += "<>";
}
s += p_dir->files[i]->deps[j];
String type = file_info->type;
if (file_info->resource_script_class) {
type += "/" + String(file_info->resource_script_class);
}

p_file->store_line(s);
PackedStringArray cache_string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StringBuilder isn't appropriate for this, is it? Code is sooo much more readable now, but just putting the thought out there.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used PackedStringArray for easier joining.

cache_string.append(file_info->file);
cache_string.append(type);
cache_string.append(itos(file_info->uid));
cache_string.append(itos(file_info->modified_time));
cache_string.append(itos(file_info->import_modified_time));
cache_string.append(itos(file_info->import_valid));
cache_string.append(file_info->import_group_file);
cache_string.append(String("<>").join({ file_info->script_class_name, file_info->script_class_extends, file_info->script_class_icon_path }));
cache_string.append(String("<>").join(file_info->deps));

p_file->store_line(String("::").join(cache_string));
}

for (int i = 0; i < p_dir->subdirs.size(); i++) {
Expand Down
Loading