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
This commit is contained in:
parent
d77a6849e6
commit
ea731f42db
Notes:
blender-bot
2023-02-14 05:52:32 +01:00
Referenced by issue #103187, Slowdown when opening add menu or search menu for the first time in the node editor Referenced by issue #102967, 3.4: Potential candidates for corrective releases
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue