Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Cache modified time of projects

kobewi7574736c03b9
diff --git a/editor/project_manager/project_list.cpp b/editor/project_manager/project_list.cpp
index 7f34a4787b2..797fc62afb2 100644
--- a/editor/project_manager/project_list.cpp
+++ b/editor/project_manager/project_list.cpp
@@ -855,17 +855,17 @@ ProjectList::Item ProjectList::load_project_data(const String &p_path, bool p_fa
uint64_t last_edited = 0;
if (cf_err == OK) {
- // The modification date marks the date the project was last edited.
- // This is because the `project.godot` file will always be modified
- // when editing a project (but not when running it).
- last_edited = FileAccess::get_modified_time(conf);
-
- String fscache = p_path.path_join(".fscache");
- if (FileAccess::exists(fscache)) {
- uint64_t cache_modified = FileAccess::get_modified_time(fscache);
- if (cache_modified > last_edited) {
- last_edited = cache_modified;
- }
+ int *cached_time = modified_time_cache.getptr(p_path);
+ if (cached_time) {
+ // Modified time may change as a result of Project Manager actions, which will affect sorting.
+ // For that reason, the time is read only once.
+ last_edited = *cached_time;
+ } else {
+ // The modification date marks the date the project was last edited.
+ // This is because the `project.godot` file will always be modified
+ // when editing a project (but not when running it).
+ last_edited = FileAccess::get_modified_time(conf);
+ modified_time_cache[p_path] = last_edited;
}
} else {
grayed = true;
diff --git a/editor/project_manager/project_list.h b/editor/project_manager/project_list.h
index 23a50c67779..8327ac8bf9b 100644
--- a/editor/project_manager/project_list.h
+++ b/editor/project_manager/project_list.h
@@ -229,6 +229,7 @@ private:
ConfigFile _config;
Vector<Item> _projects;
+ static inline HashMap<String, int> modified_time_cache;
int _icon_load_index = 0;
bool project_opening_initiated = false;