@@ -728,16 +728,25 @@ void SlowByteLengthUtf8(const FunctionCallbackInfo<Value>& args) {
728
728
args.GetReturnValue ().Set (args[0 ].As <String>()->Utf8Length (env->isolate ()));
729
729
}
730
730
731
- uint32_t FastByteLengthUtf8 (Local<Value> receiver,
732
- const v8::FastOneByteString& source) {
731
+ uint32_t FastByteLengthUtf8 (
732
+ Local<Value> receiver,
733
+ Local<Value> sourceValue,
734
+ v8::FastApiCallbackOptions& options) { // NOLINT(runtime/references)
735
+ TRACK_V8_FAST_API_CALL (" Buffer::FastByteLengthUtf8" );
736
+ auto isolate = options.isolate ;
737
+ HandleScope handleScope (isolate);
738
+ Local<String> sourceStr;
739
+ CHECK (
740
+ sourceValue->ToString (isolate->GetCurrentContext ()).ToLocal (&sourceStr));
741
+ Utf8Value source (isolate, sourceStr);
733
742
// For short inputs, the function call overhead to simdutf is maybe
734
743
// not worth it, reserve simdutf for long strings.
735
- if (source.length > 128 ) {
736
- return simdutf::utf8_length_from_latin1 (source.data , source.length );
744
+ if (source.length () > 128 ) {
745
+ return simdutf::utf8_length_from_latin1 (source.out () , source.length () );
737
746
}
738
747
739
- uint32_t length = source.length ;
740
- const auto input = reinterpret_cast <const uint8_t *>(source.data );
748
+ uint32_t length = source.length () ;
749
+ const auto input = reinterpret_cast <const uint8_t *>(source.out () );
741
750
742
751
uint32_t answer = length;
743
752
uint32_t i = 0 ;
0 commit comments