Repository navigation
perf(napi): owned_string_without_coercion use unchecked string conversion - #3709
Conversation
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
5293b42 to
41a7389
Compare
…ersion `napi_get_value_string_utf8` only writes valid UTF-8, and `String::from_napi_value` already relies on that. Use `String::from_utf8_unchecked` here too, instead of validating the bytes again. The `None` result for invalid UTF-8 could never happen. Add a test that captures lone surrogates, the one input where the skipped check could matter, through both paths in `owned_reason_without_coercion` (an `Error` message and a string primitive). Co-Authored-By: Claude Opus 5.5 <[email protected]>
41a7389 to
34a5237
Compare
napi_get_value_string_utf8only writes valid UTF-8, andString::from_napi_valuealready relies on that.Use
String::from_utf8_uncheckedinowned_string_without_coerciontoo, instead of validating the bytes again. TheNoneresult for invalid UTF-8 could never happen.Adds a test that captures lone surrogates (the one input where the skipped check could matter) through both paths in
owned_reason_without_coercion: anErrormessage and a string primitive.Based on top of #3708.
Summary by CodeRabbit