@@ -585,26 +585,17 @@ void StringSlice(const FunctionCallbackInfo<Value>& args) {
585585 }
586586}
587587
588- void CopyImpl (Local<Value> source_obj,
589- Local<Value> target_obj,
590- const uint32_t target_start,
591- const uint32_t source_start,
592- const uint32_t to_copy) {
593- ArrayBufferViewContents<char > source (source_obj);
594- SPREAD_BUFFER_ARG (target_obj, target);
595-
596- memmove (target_data + target_start, source.data () + source_start, to_copy);
597- }
598-
599588// Assume caller has properly validated args.
600589void SlowCopy (const FunctionCallbackInfo<Value>& args) {
601- Local<Value> source_obj = args[0 ];
602- Local<Value> target_obj = args[1 ];
603590 const uint32_t target_start = args[2 ].As <Uint32>()->Value ();
604591 const uint32_t source_start = args[3 ].As <Uint32>()->Value ();
605592 const uint32_t to_copy = args[4 ].As <Uint32>()->Value ();
606593
607- CopyImpl (source_obj, target_obj, target_start, source_start, to_copy);
594+ ArrayBufferView::FastCopy (ArrayBufferView::Cast (*args[0 ]),
595+ source_start,
596+ ArrayBufferView::Cast (*args[1 ]),
597+ target_start,
598+ to_copy);
608599
609600 args.GetReturnValue ().Set (to_copy);
610601}
@@ -618,10 +609,12 @@ uint32_t FastCopy(Local<Value> receiver,
618609 uint32_t to_copy,
619610 // NOLINTNEXTLINE(runtime/references)
620611 FastApiCallbackOptions& options) {
621- HandleScope scope (options.isolate );
622-
623- CopyImpl (source_obj, target_obj, target_start, source_start, to_copy);
624-
612+ TRACK_V8_FAST_API_CALL (" buffer.copy" );
613+ ArrayBufferView::FastCopy (ArrayBufferView::Cast (*source_obj),
614+ source_start,
615+ ArrayBufferView::Cast (*target_obj),
616+ target_start,
617+ to_copy);
625618 return to_copy;
626619}
627620
0 commit comments