Improved handling of invalid accept headers.#2226
Merged
Conversation
accept headers.
jeremyevans
approved these changes
Jul 2, 2024
Contributor
jeremyevans
left a comment
There was a problem hiding this comment.
Even in recent Ruby versions, this new approach is much faster than the previous approach. If you can use strings instead of regexps, it's usually faster to use strings.
| end | ||
| [attribute, quality] | ||
| end | ||
| end.compact |
Contributor
There was a problem hiding this comment.
I think we should use a temporary variable and map! and compact! to avoid unnecessary array allocations.
jeremyevans
approved these changes
Jul 2, 2024
| [attribute, quality] | ||
| end | ||
|
|
||
| parts.compact |
Contributor
There was a problem hiding this comment.
parts.compact!; parts to save another array allocation.
Member
Author
There was a problem hiding this comment.
Sorry, I missed this but intended to do that. Thanks for calling it out.
17a0b30 to
3e44b93
Compare
jeremyevans
approved these changes
Jul 2, 2024
Member
Author
|
Thanks @jeremyevans for your quick and excellent reviews. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Possible fix for #2225.
A few thoughts:
split(/\s*,\s*/)on recent versions of Ruby? Could we return to using it in the future if the performance isn't bad?filter_mapis only available in Ruby 2.7+ - I know we decided to support old Rubies for as long as possible and I don't think we should change that right now, but I just wanted to call out that there is (probably) a slight loss of performance due to backwards compatibility.