File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,19 @@ void BindingData::EncodeInto(const FunctionCallbackInfo<Value>& args) {
198198 char * write_result = static_cast <char *>(buf->Data ()) + dest->ByteOffset ();
199199 size_t dest_length = dest->ByteLength ();
200200
201+ // For small strings (length <= 32), use the old V8 path for better performance
202+ if (source->Length () <= 32 ) {
203+ size_t nchars;
204+ size_t written = source->WriteUtf8V2 (isolate,
205+ write_result,
206+ dest_length,
207+ String::WriteFlags::kReplaceInvalidUtf8 ,
208+ &nchars);
209+ binding_data->encode_into_results_buffer_ [0 ] = nchars;
210+ binding_data->encode_into_results_buffer_ [1 ] = written;
211+ return ;
212+ }
213+
201214 size_t read = 0 ;
202215 size_t written = 0 ;
203216 v8::String::ValueView view (isolate, source);
You can’t perform that action at this time.
0 commit comments