Skip to content

Commit

Permalink
Cache plugins' master flag
Browse files Browse the repository at this point in the history
Avoiding the overhead of checking with esplugin improves sorting performance by 5%.
  • Loading branch information
Ortham committed Jan 17, 2025
1 parent 5af5b8c commit e51b78e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/api/sorting/plugin_sorting_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ PluginSortingData::PluginSortingData(
#endif
plugin_(plugin),
name_(plugin == nullptr ? std::string() : plugin->GetName()),
isMaster_(plugin != nullptr && plugin->IsMaster()),
group_(userMetadata.GetGroup().value_or(
masterlistMetadata.GetGroup().value_or(Group::DEFAULT_NAME))),
masterlistLoadAfter_(masterlistMetadata.GetLoadAfterFiles()),
Expand Down Expand Up @@ -92,12 +93,10 @@ PluginSortingData::PluginSortingData(

const std::string& PluginSortingData::GetName() const { return name_; }

bool PluginSortingData::IsMaster() const {
return plugin_ != nullptr && plugin_->IsMaster();
}
bool PluginSortingData::IsMaster() const { return isMaster_; }

bool PluginSortingData::IsBlueprintMaster() const {
return plugin_ != nullptr && plugin_->IsMaster() &&
return isMaster_ &&
plugin_->IsBlueprintPlugin();
}

Expand Down
1 change: 1 addition & 0 deletions src/api/sorting/plugin_sorting_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class PluginSortingData {
private:
const PluginSortingInterface* plugin_{nullptr};
std::string name_;
bool isMaster_{false};
std::string group_;

std::vector<File> masterlistLoadAfter_;
Expand Down

0 comments on commit e51b78e

Please sign in to comment.