Skip to content

Small optimization in TaxonomyService#8775

Merged
MatteoPiovanelli merged 1 commit into
OrchardCMS:devfrom
LaserSrl:PR/memorize_taxonomy_queries
Mar 15, 2024
Merged

Small optimization in TaxonomyService#8775
MatteoPiovanelli merged 1 commit into
OrchardCMS:devfrom
LaserSrl:PR/memorize_taxonomy_queries

Conversation

@MatteoPiovanelli

Copy link
Copy Markdown
Contributor

Memorize results of queries to prevent repeated execution within a request.
We noticed a few instances where the same query would be invoked several times in the same request. For example, when several contentItems of a same contentType are in the same list.

This allows skipping a few of those queries.

public ILogger Logger { get; set; }
public Localizer T { get; set; }

private IEnumerable<TaxonomyPart> _taxonomies;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private IEnumerable<TaxonomyPart> _taxonomies;
private List<TaxonomyPart> _taxonomies;

Since the type is known and this is a private member

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless it's not what the method returns

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IContentQuery<T>.List() (which is what's assigned and eventually returned here) returns an IEnumerable<T>. Definitely not a List<T>.

@MatteoPiovanelli
MatteoPiovanelli merged commit 4a05e77 into OrchardCMS:dev Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants