@@ -585,26 +585,19 @@ 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 ];
603- const uint32_t target_start = args[2 ].As <Uint32>()->Value ();
604- const uint32_t source_start = args[3 ].As <Uint32>()->Value ();
605- const uint32_t to_copy = args[4 ].As <Uint32>()->Value ();
606-
607- CopyImpl (source_obj, target_obj, target_start, source_start, to_copy);
590+ auto source_obj = args[0 ].As <ArrayBufferView>();
591+ auto target_obj = args[1 ].As <ArrayBufferView>();
592+ auto target_start = args[2 ].As <Uint32>()->Value ();
593+ auto source_start = args[3 ].As <Uint32>()->Value ();
594+ auto to_copy = args[4 ].As <Uint32>()->Value ();
595+
596+ ArrayBufferView::FastCopy (source_obj,
597+ source_start,
598+ target_obj,
599+ target_start,
600+ to_copy);
608601
609602 args.GetReturnValue ().Set (to_copy);
610603}
@@ -618,10 +611,12 @@ uint32_t FastCopy(Local<Value> receiver,
618611 uint32_t to_copy,
619612 // NOLINTNEXTLINE(runtime/references)
620613 FastApiCallbackOptions& options) {
621- HandleScope scope (options.isolate );
622-
623- CopyImpl (source_obj, target_obj, target_start, source_start, to_copy);
624-
614+ TRACK_V8_FAST_API_CALL (" buffer.copy" );
615+ ArrayBufferView::FastCopy (source_obj.As <ArrayBufferView>(),
616+ source_start,
617+ target_obj.As <ArrayBufferView>(),
618+ target_start,
619+ to_copy);
625620 return to_copy;
626621}
627622
0 commit comments