@@ -585,26 +585,15 @@ 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 ]), source_start,
595+ ArrayBufferView::Cast (*args[1 ]), target_start,
596+ to_copy);
608597
609598 args.GetReturnValue ().Set (to_copy);
610599}
@@ -618,10 +607,10 @@ uint32_t FastCopy(Local<Value> receiver,
618607 uint32_t to_copy,
619608 // NOLINTNEXTLINE(runtime/references)
620609 FastApiCallbackOptions& options) {
621- HandleScope scope (options. isolate );
622-
623- CopyImpl (source_obj, target_obj, target_start, source_start, to_copy);
624-
610+ TRACK_V8_FAST_API_CALL ( " buffer.copy " );
611+ ArrayBufferView::FastCopy ( ArrayBufferView::Cast (*source_obj), source_start,
612+ ArrayBufferView::Cast (* target_obj) , target_start,
613+ to_copy);
625614 return to_copy;
626615}
627616
0 commit comments