[Bf-blender-cvs] [a0ed3601c9f] geometry-nodes-simulation: Fix T103187: Opening node search menu is slow because of assets.

Julian Eisel noreply at git.blender.org
Mon Dec 19 19:05:25 CET 2022


Commit: a0ed3601c9f299027d7f194894e6d81f1c584af9
Author: Julian Eisel
Date:   Fri Dec 16 17:01:03 2022 +0100
Branches: geometry-nodes-simulation
https://developer.blender.org/rBa0ed3601c9f299027d7f194894e6d81f1c584af9

Fix T103187: Opening node search menu is slow because of assets.

Avoid utility function call that would query the file system, this was a
bottleneck. The path joining was also problematic. See patch for more
details.

Differential Revision: https://developer.blender.org/D16768

Reviewed by: Jacques Lucke

===================================================================

M	source/blender/editors/space_file/filelist.cc

===================================================================

diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc
index bf0f9c865a8..c40ba5d016b 100644
--- a/source/blender/editors/space_file/filelist.cc
+++ b/source/blender/editors/space_file/filelist.cc
@@ -323,7 +323,6 @@ static void filelist_readjob_main_assets(FileListReadJob *job_params,
 
 /* helper, could probably go in BKE actually? */
 static int groupname_to_code(const char *group);
-static uint64_t groupname_to_filter_id(const char *group);
 
 static void filelist_cache_clear(FileListEntryCache *cache, size_t new_size);
 static bool filelist_intern_entry_is_main_file(const FileListInternEntry *intern_entry);
@@ -751,7 +750,7 @@ static bool is_filtered_file(FileListInternEntry *file,
 }
 
 static bool is_filtered_id_file_type(const FileListInternEntry *file,
-                                     const char *id_group,
+                                     const short id_code,
                                      const char *name,
                                      const FileListFilter *filter)
 {
@@ -761,12 +760,12 @@ static bool is_filtered_id_file_type(const FileListInternEntry *file,
 
   /* We only check for types if some type are enabled in filtering. */
   if ((filter->filter || filter->filter_id) && (filter->flags & FLF_DO_FILTER)) {
-    if (id_group) {
+    if (id_code) {
       if (!name && (filter->flags & FLF_HIDE_LIB_DIR)) {
         return false;
       }
 
-      uint64_t filter_id = groupname_to_filter_id(id_group);
+      const uint64_t filter_id = BKE_idtype_idcode_to_idfilter(id_code);
       if (!(filter_id & filter->filter_id)) {
         return false;
       }
@@ -851,15 +850,11 @@ static bool is_filtered_asset(FileListInternEntry *file, FileListFilter *filter)
 }
 
 static bool is_filtered_lib_type(FileListInternEntry *file,
-                                 const char *root,
+                                 const char * /*root*/,
                                  FileListFilter *filter)
 {
-  char path[FILE_MAX_LIBEXTRA], dir[FILE_MAX_LIBEXTRA], *group, *name;
-
-  BLI_path_join(path, sizeof(path), root, file->relpath);
-
-  if (BLO_library_path_explode(path, dir, &group, &name)) {
-    return is_filtered_id_file_type(file, group, name, filter);
+  if (file->typeflag & FILE_TYPE_BLENDERLIB) {
+    return is_filtered_id_file_type(file, file->blentype, file->name, filter);
   }
   return is_filtered_file_type(file, filter);
 }
@@ -881,7 +876,7 @@ static bool is_filtered_main_assets(FileListInternEntry *file,
                                     FileListFilter *filter)
 {
   /* "Filtered" means *not* being filtered out... So return true if the file should be visible. */
-  return is_filtered_id_file_type(file, file->relpath, file->name, filter) &&
+  return is_filtered_id_file_type(file, file->blentype, file->name, filter) &&
          is_filtered_asset(file, filter);
 }
 
@@ -2882,13 +2877,6 @@ static int groupname_to_code(const char *group)
   return buf[0] ? BKE_idtype_idcode_from_name(buf) : 0;
 }
 
-static uint64_t groupname_to_filter_id(const char *group)
-{
-  int id_code = groupname_to_code(group);
-
-  return BKE_idtype_idcode_to_idfilter(id_code);
-}
-
 /**
  * From here, we are in 'Job Context',
  * i.e. have to be careful about sharing stuff between background working thread.



More information about the Bf-blender-cvs mailing list