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

Replace Util.downcase_ascii with String.downcase(&1, :ascii) #424

Merged
merged 1 commit into from
Feb 11, 2024

Conversation

IceDragon200
Copy link
Contributor

Summary

This PR removes calls to Mint's original downcase_ascii/1 which was found to be slower than Elixir's stock downcase with the :ascii option.

Related

Closes #420

Notes

I unrolled HTTP1.Parser.header_name/1's atom case for clarity, as inline pipes on the same line can be hard to read, I hope this is okay.

@@ -68,4 +68,8 @@ defmodule Mint.HTTP1.Parse do
do: token_list_downcase(rest, acc)

defp token_list_sep_downcase(_rest, _acc), do: :error

@spec downcase_ascii_char(byte()) :: byte()
Copy link
Member

Choose a reason for hiding this comment

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

We usually don't add specs to private functions.

Suggested change
@spec downcase_ascii_char(byte()) :: byte()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Also moved downcase_ascii_char/1 to HTTP1.Parse as it's the only module that uses it now.
@whatyouhide
Copy link
Contributor

I'll fix the warnings locally. Thanks @IceDragon200 💟

@whatyouhide whatyouhide merged commit 99bd9bd into elixir-mint:main Feb 11, 2024
3 of 4 checks passed
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.

Mint's downcase_ascii/1 is slower than String.downcase(str, :ascii)
3 participants