src: remove double encoding validation on fatal path#63587
Open
araujogui wants to merge 2 commits into
Open
Conversation
92897bc to
a2ccfb5
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR optimizes UTF-8 decoding in the encoding binding by avoiding redundant UTF-8 validation when input has already been validated.
Changes:
- Added
StringBytes::EncodeValidatedUTF8()API for encoding already-validated UTF-8. - Refactored the fast UTF-8→UTF-16 conversion into a shared helper (
EncodeKnownValidNonAsciiUTF8). - Updated
BindingData::DecodeUTF8()to use the new API after performing UTF-8 validation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/string_bytes.h | Declares a new EncodeValidatedUTF8() entry point for already-validated UTF-8. |
| src/string_bytes.cc | Implements EncodeValidatedUTF8() and factors out the fast conversion helper used by both code paths. |
| src/encoding_binding.cc | Uses EncodeValidatedUTF8() after explicit UTF-8 validation to avoid re-validation overhead. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #63587 +/- ##
==========================================
- Coverage 90.33% 90.31% -0.03%
==========================================
Files 730 730
Lines 234362 234671 +309
Branches 43906 43946 +40
==========================================
+ Hits 211713 211941 +228
- Misses 14371 14450 +79
- Partials 8278 8280 +2
🚀 New features to boost your workflow:
|
71e12c1 to
727b683
Compare
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
Signed-off-by: Guilherme Araújo <arauujogui@gmail.com>
727b683 to
6a919f6
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Create
StringBytes::EncodeValidatedUTF8to avoid double UTF-8 validation on fatal path