MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / _ensure_script_cache_complete

Method _ensure_script_cache_complete

utility/gdre_settings.cpp:2152–2227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2150} //namespace
2151
2152void GDRESettings::_ensure_script_cache_complete() {
2153 Vector<String> filters;
2154 // We don't need this for C# scripts since they already get their base class script paths via the decompiler, and it's a significant performance hit loading them.
2155 if (has_loaded_dotnet_assembly()) {
2156 filters.push_back("*.cs");
2157 }
2158 // Don't attempt to load compiled scripts if we don't have a valid version.
2159 if (get_bytecode_revision() != 0) {
2160 filters.append_array({ "*.gd", "*.gdc", "*.gde" });
2161 }
2162 if (filters.is_empty()) {
2163 return;
2164 }
2165 cached_scripts.clear();
2166 auto script_paths = get_file_list(filters);
2167 Vector<ScriptCacheTask::ScriptCacheTaskToken> tokens;
2168 for (auto &path : script_paths) {
2169 auto ext = path.get_extension().to_lower();
2170 bool bytecode_script = ext == "gdc" || ext == "gde";
2171 bool is_gdscript = ext == "gd" || bytecode_script;
2172 String orig_path = bytecode_script ? path.get_basename() + ".gd" : path;
2173 tokens.push_back(ScriptCacheTask::ScriptCacheTaskToken{ orig_path, is_gdscript, {} });
2174 }
2175 if (tokens.size() == 0) {
2176 return;
2177 }
2178
2179 GDRELogger::set_silent_errors(true);
2180 ScriptCacheTask task;
2181 // any less than this and it's faster to just do it in one thread
2182 if (tokens.size() > 50) {
2183 TaskManager::get_singleton()->run_multithreaded_group_task(
2184 &task,
2185 &ScriptCacheTask::do_task,
2186 tokens.ptrw(),
2187 tokens.size(),
2188 &ScriptCacheTask::get_description,
2189 "GDRESettings::load_pack_gdscript_cache",
2190 RTR("Loading GDScript cache..."),
2191 false);
2192
2193 } else {
2194 for (int i = 0; i < tokens.size(); i++) {
2195 task.do_task(i, tokens.ptrw());
2196 }
2197 }
2198 cached_scripts.reserve(tokens.size());
2199 GDRELogger::set_silent_errors(false);
2200 for (int i = 0; i < tokens.size(); i++) {
2201 if (tokens[i].script.is_valid()) {
2202 cached_scripts.push_back(tokens[i].script);
2203 }
2204 if (!tokens[i].d.is_empty()) {
2205#ifdef DEBUG_ENABLED
2206 if (script_cache.has(tokens[i].orig_path)) {
2207 String err_msg = "";
2208 // older script cache entries did not have "is_abstract" or "is_tool" keys, so ours may be bigger
2209 if (script_cache[tokens[i].orig_path].size() > tokens[i].d.size()) {

Callers

nothing calls this directly

Calls 8

push_backMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
do_taskMethod · 0.45
reserveMethod · 0.45
is_validMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected