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

Simplified the Entities.escape method #2183

Merged
merged 2 commits into from
Jul 30, 2024
Merged

Simplified the Entities.escape method #2183

merged 2 commits into from
Jul 30, 2024

Conversation

jhy
Copy link
Owner

@jhy jhy commented Jul 30, 2024

Introduced an options bitset instead of all those boolean method options. Reduced cyclomatic complexity of from 29 to 14.

Improved throughput of escape around 22% if the content contains characters in supplemental plane, by no longer going through the charset encoder to test can encode, but pushing it into the CoreCharset. That removes a ByteBuffer allocation on each hit.

jhy added 2 commits July 30, 2024 12:47
Introduced an options bitset instead of all those boolean method options. Reduced cyclomatic complexity of from 29 to 14.

Improved throughput of escape around 22% if the content contains characters in supplemental plane, by no longer going through the charset encoder to test can encode, but pushing it into the CoreCharset. That removes a ByteBuffer allocation on each hit.
@jhy
Copy link
Owner Author

jhy commented Jul 30, 2024

I perf tested using this wiki list of colors, which has some interesting attributes like <p title="𝗛𝗦𝗩 (34° 14% 98%)&#10;𝗥𝗚𝗕 (250 235 215)&#10;𝗛𝗘𝗫 #FAEBD7">. Those are mathematical sans-serif bold capital h etc; &#120283; if encoded in ASCII (in UTF we don't need to encode).

Average html() operations per second went from ~ 156 to ~ 186.

@jhy jhy self-assigned this Jul 30, 2024
@jhy jhy added this to the 1.18.2 milestone Jul 30, 2024
@jhy jhy merged commit 60281c5 into master Jul 30, 2024
12 checks passed
@jhy jhy deleted the simplify-entities branch July 30, 2024 03:06
jhy added a commit that referenced this pull request Jul 30, 2024
Attribute: removed regex matchers to check for key validity, using a simple scan now.

Entities: use a charBuf to append supplemental characters

Improves on #2183
@jhy
Copy link
Owner Author

jhy commented Jul 30, 2024

And some further improvements in 27e7d5f. Getting around 235 ops/sec (from 156 -- so about 49% faster now!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant