-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructure UTF-16 to UTF-8 encode to avoid
unsafe
.
Per suggestion by @RReverser in rust-lang/rust#55147 This change also makes the output buffer size requirement for UTF-16 to UTF-8 encode normal (number of input code units times three instead of the previous input code units times three plus one where the last code unit was never written into but had to be there for space checks).
- Loading branch information
Showing
1 changed file
with
81 additions
and
58 deletions.
There are no files selected for viewing
This file contains 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
a30a3d4
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.
The performance was worse with this changeset than without it.
a30a3d4
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.
Hmm, how big of a difference? Instruction-wise the generated code is even simpler than
checked_add
+unsafe
, so this is surprising.a30a3d4
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.
Up to 30% slow-down:
Another attempt at rewrite required 2018 edition (non-lexical lifetimes) and was better than the above but still worse than the original. Results in comparison to the original
unsafe
-using code: