-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Conversation
Reuse 1 StringBuilder to generate multiple clauses instead of creating Lists of strings to join
} | ||
|
||
// Remove last, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Remove last, | |
// Remove last "," |
I initially thought this was an unfinished comment
{ | ||
whereClauses.Add(ratingClauseString + ")"); | ||
whereClauses.Add(clauseBuilder.Append(')').ToString()); | ||
clauseBuilder.Length = 0; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All StringBuilder.Clear() does is setting length to 0
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Reuse 1 StringBuilder to generate multiple clauses instead of creating Lists of strings to join