Add ASSUMEs for UTF-8 byte lengths #23680
Merged
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.
The maximum number of bytes in a Perl extended UTF-8 character is 13 on ASCII platforms; 14 on EBCDIC. Yet the variable that returns that number is a Size_t. By adding these clues to these inline functions, the compiler may be able to do some optimizations.
This isn't done here on another inline function, utf8_to_uv_msgs(). That is because it currently returns the call of a non-inline function, so the ASSUME would be unreachable code. I don't know if that actually matters. Or that function's boolean result could be stored in a temporary the ASSUME done, and then utf8_to_uv_msgs() would return the temporary's value.
Opinions welcome