perf(ext/ffi): Revert UTF-8 validity check from getCString #17741
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.
I previously added a UTF-8 validity check to the
getCString
FFI API thinking that it was essentially a fluke or at least poorly thought out to pass in possibly invalid UTF-8 into theNewFromUtf8
V8 String API.It seems this is not the case. I've added tests to rusty_v8 (denoland/rusty_v8#1190) to check that the API handles invalid UTF-8 sequences and also added similar or equal tests to FFI tests here locally. The local tests verify that not only does the API work, it also produces the equivalent result as using
TextDecoder
would.The performance difference in our bench case is about 5-15 nanoseconds out of roughly 150ns. 2 ** 28 byte string shows a similar difference, going from 115 ms to 104 ms.