Skip to content

Commit 2f8d2ad

Browse files
committed
perf: cache resolved indexed directories to avoid repeated resolution
Made the `dirs` variable in `defaultIndexedDirectory()` static const so that `getResolvedIndexedDirectories()` is only called once. This avoids redundant directory resolution on every invocation of the default indexed directory lookup. 将`defaultIndexedDirectory()`中的`dirs`变量声明为static const, 使`getResolvedIndexedDirectories()`仅被调用一次,避免每次查找默认 索引目录时重复进行目录解析。 Log: 缓存已解析的索引目录避免重复解析 PMS: https://pms.uniontech.com/bug-view-361809.html Influence: 减少重复调用时的冗余文件系统操作,提升频繁查询默认索引目录的搜索场景性能。需确认应用重启后仍能正确加载索引目录配置变更,以及静态初始化不存在线程安全问题。
1 parent 27fe7a5 commit 2f8d2ad

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/dfm-search/dfm-search-lib/utils/searchutility.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ QStringList defaultContentSearchExtensions()
514514

515515
QStringList defaultIndexedDirectory()
516516
{
517-
const QStringList &dirs = getResolvedIndexedDirectories();
517+
static const QStringList &dirs = getResolvedIndexedDirectories();
518518

519519
if (dirs.isEmpty()) {
520520
return QStringList();

0 commit comments

Comments
 (0)