From a02ab9ed033daa6f9ead453cbdffed7d9f751d02 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 b319a74ebaedbf..aba95e47f353ad 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 61f4da655c93cd..a1f7293bfff58f 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)