Skip to content

Commit

Permalink
src: avoid copy when creating Blob
Browse files Browse the repository at this point in the history
PR-URL: #44616
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
  • Loading branch information
tniessen authored and juanarbol committed Oct 11, 2022
1 parent 9a469be commit 24172ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
8 changes: 3 additions & 5 deletions src/node_blob.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,9 @@ bool Blob::HasInstance(Environment* env, v8::Local<v8::Value> object) {
return GetConstructorTemplate(env)->HasInstance(object);
}

BaseObjectPtr<Blob> Blob::Create(
Environment* env,
const std::vector<BlobEntry> store,
size_t length) {

BaseObjectPtr<Blob> Blob::Create(Environment* env,
const std::vector<BlobEntry>& store,
size_t length) {
HandleScope scope(env->isolate());

Local<Function> ctor;
Expand Down
11 changes: 4 additions & 7 deletions src/node_blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,13 @@ class Blob : public BaseObject {
static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
Environment* env);

static BaseObjectPtr<Blob> Create(
Environment* env,
const std::vector<BlobEntry> store,
size_t length);
static BaseObjectPtr<Blob> Create(Environment* env,
const std::vector<BlobEntry>& store,
size_t length);

static bool HasInstance(Environment* env, v8::Local<v8::Value> object);

const std::vector<BlobEntry> entries() const {
return store_;
}
const std::vector<BlobEntry>& entries() const { return store_; }

void MemoryInfo(MemoryTracker* tracker) const override;
SET_MEMORY_INFO_NAME(Blob)
Expand Down

0 comments on commit 24172ca

Please sign in to comment.