From c6773bc3e6b5aca8473cef5b2b6a08d2ae4a4649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Wed, 14 Sep 2022 23:44:31 +0200 Subject: [PATCH] src: avoid copy when creating Blob PR-URL: https://github.com/nodejs/node/pull/44616 Reviewed-By: Joyee Cheung Reviewed-By: Anna Henningsen Reviewed-By: Daeyeon Jeong --- src/node_blob.cc | 8 +++----- src/node_blob.h | 11 ++++------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/node_blob.cc b/src/node_blob.cc index d785aa60332d61..b290273466c686 100644 --- a/src/node_blob.cc +++ b/src/node_blob.cc @@ -71,11 +71,9 @@ bool Blob::HasInstance(Environment* env, v8::Local object) { return GetConstructorTemplate(env)->HasInstance(object); } -BaseObjectPtr Blob::Create( - Environment* env, - const std::vector store, - size_t length) { - +BaseObjectPtr Blob::Create(Environment* env, + const std::vector& store, + size_t length) { HandleScope scope(env->isolate()); Local ctor; diff --git a/src/node_blob.h b/src/node_blob.h index 80e59a1c51c0bd..f0340f313bde6f 100644 --- a/src/node_blob.h +++ b/src/node_blob.h @@ -45,16 +45,13 @@ class Blob : public BaseObject { static v8::Local GetConstructorTemplate( Environment* env); - static BaseObjectPtr Create( - Environment* env, - const std::vector store, - size_t length); + static BaseObjectPtr Create(Environment* env, + const std::vector& store, + size_t length); static bool HasInstance(Environment* env, v8::Local object); - const std::vector entries() const { - return store_; - } + const std::vector& entries() const { return store_; } void MemoryInfo(MemoryTracker* tracker) const override; SET_MEMORY_INFO_NAME(Blob)