Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
src: avoid copy when creating Blob
  • Loading branch information
jasnell authored and tniessen committed Sep 12, 2022
commit 7a4301e3dc8841136eec9b97e5c6f013dcbc00ec
8 changes: 3 additions & 5 deletions src/node_blob.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,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