-
Notifications
You must be signed in to change notification settings - Fork 9
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
Speed-up HTML escaping a little bit #100
Conversation
rinja/src/html.rs
Outdated
const ESCAPED_BUF_LEN: usize = b"&#__;".len(); | ||
|
||
#[test] | ||
fn simple() { |
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.
Please pick a better name. Not very helpful if it ever fails. 😉
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.
If "simple" is broken, then "simply everything" is broken? :D Changed.
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.
Try explaining that to future you. 😛
rinja/src/html.rs
Outdated
} | ||
|
||
const MIN_CHAR: u8 = b'"'; | ||
const MAX_CHAR: u8 = b'>'; | ||
/// If the character needs HTML escaping, then return the decimal representation of the codepoint. |
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.
/// If the character needs HTML escaping, then return the decimal representation of the codepoint. | |
/// Returns the decimal representation of the codepoint if the character needs HTML escaping. |
rinja/src/html.rs
Outdated
} | ||
|
||
/// For characters that need HTML escaping, the codepoint formatted as decimal digits, |
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 think a word is missing here:
/// For characters that need HTML escaping, the codepoint formatted as decimal digits, | |
/// For characters that need HTML escaping, the codepoint is formatted as decimal digits, |
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.
Stupid question: How can I add a "suggested change" when I review code?
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.
Welcome to "github trick of the day" :D
Like this:
```suggestion
yo
```
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.
Ahhh, thank you! :D
```text $ cargo bench --bench escape Before the PR: [3.6464 µs 3.6512 µs 3.6564 µs] With the PR: [3.3633 µs 3.3753 µs 3.3887 µs] ``` Around 7% faster.
Oh, I just noticed that we are at issue #100 already! 🥳 |
We're doing great together. Let's hope it'll continue for a long time. 🎉 |
I hope so, too! :) |
❤️ |
Around 7% faster.