Skip to content

optimize Repository::addCustomSearchPath

There is no need to do a reload, just add items from the new directory.

repository_benchmark -iterations 100 benchmarkRepositoryLoad: 768ms -> 441ms


I note, however, a problem with DefinitionData::get(def)->clear() in reload():

  • The definition becomes invalid and can no longer be loaded since fileName is empty. The definition keeps a reference to the repo.
    This contradicts the comment in the function because Definition can no longer be reloaded: "[...] so we can re-lookup to make references persist over repo reloads"
  • reload() throws out the definitions and consequently the Repository destructor cannot set DefinitionData::repo to null.

As a result, we end up with an invalid definition that can no longer be loaded and potentially points to a repo that no longer exists. The only thing the user can do is to discard all these retained definitions and use the new ones. Done I suppose via aboutToReload() / reloaded() or manually.

I think we can delete DefinitionData::clear() and invalidate the definitions in reload by simply setting fileName to empty or/and repo to null. What do you think?

Edited by jonathan poelen

Merge request reports

Loading