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 e70bd47 commit 9af9206Copy full SHA for 9af9206
src/node_i18n.cc
@@ -287,6 +287,14 @@ void Transcode(const FunctionCallbackInfo<Value>&args) {
287
const enum encoding toEncoding = ParseEncoding(isolate, args[2], BUFFER);
288
289
if (SupportedEncoding(fromEncoding) && SupportedEncoding(toEncoding)) {
290
+ // If encodings are the same then there is nothing to transcode and we can
291
+ // just copy the buffer
292
+ if (fromEncoding == toEncoding) {
293
+ MaybeStackBuffer<char> stackbuf(input.length());
294
+ memcpy(stackbuf.out(), input.data(), input.length());
295
+ args.GetReturnValue().Set(Buffer::New(env, &stackbuf).ToLocalChecked());
296
+ return;
297
+ }
298
TranscodeFunc tfn = &Transcode;
299
switch (fromEncoding) {
300
case ASCII:
0 commit comments