We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eaced01 commit ee71c43Copy full SHA for ee71c43
1 file changed
src/encoding_binding.cc
@@ -198,6 +198,19 @@ void BindingData::EncodeInto(const FunctionCallbackInfo<Value>& args) {
198
char* write_result = static_cast<char*>(buf->Data()) + dest->ByteOffset();
199
size_t dest_length = dest->ByteLength();
200
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
+
214
size_t read = 0;
215
size_t written = 0;
216
v8::String::ValueView view(isolate, source);
0 commit comments