Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the amount of allocations in GetWhereClauses #10114

Merged
merged 3 commits into from
Aug 21, 2023

Conversation

Bond-009
Copy link
Member

Reuse 1 StringBuilder to generate multiple clauses instead of creating Lists of strings to join

Reuse 1 StringBuilder to generate multiple clauses instead of creating Lists of strings to join
}

// Remove last,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Remove last,
// Remove last ","

I initially thought this was an unfinished comment

{
whereClauses.Add(ratingClauseString + ")");
whereClauses.Add(clauseBuilder.Append(')').ToString());
clauseBuilder.Length = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we clear the clause builder even if length is 0?

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't be necessary afaik

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I would argue the intent with Clear is... Clearer

Copy link
Member

Choose a reason for hiding this comment

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

I meant to say if the length is 1.. my mistake!

Copy link
Member Author

Choose a reason for hiding this comment

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

@cvium I used .length = 0 instead of .clear bc it's done this way in the existing code, but I could change all occurrences if that's preferred.

Copy link
Member

Choose a reason for hiding this comment

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

@Bond-009 Doesn't really matter to me

@Bond-009 Bond-009 merged commit 84643e3 into jellyfin:master Aug 21, 2023
18 checks passed
@Bond-009 Bond-009 deleted the clausebuilder branch August 21, 2023 16:38
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.

None yet

4 participants