Skip to content

Commit 8de4849

Browse files
tniessenRafaelGSS
authored andcommitted
src: avoid copy when creating Blob
PR-URL: #44616 Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Daeyeon Jeong <[email protected]>
1 parent 938751b commit 8de4849

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/node_blob.cc

+3-5
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,9 @@ bool Blob::HasInstance(Environment* env, v8::Local<v8::Value> object) {
7171
return GetConstructorTemplate(env)->HasInstance(object);
7272
}
7373

74-
BaseObjectPtr<Blob> Blob::Create(
75-
Environment* env,
76-
const std::vector<BlobEntry> store,
77-
size_t length) {
78-
74+
BaseObjectPtr<Blob> Blob::Create(Environment* env,
75+
const std::vector<BlobEntry>& store,
76+
size_t length) {
7977
HandleScope scope(env->isolate());
8078

8179
Local<Function> ctor;

src/node_blob.h

+4-7
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,13 @@ class Blob : public BaseObject {
4545
static v8::Local<v8::FunctionTemplate> GetConstructorTemplate(
4646
Environment* env);
4747

48-
static BaseObjectPtr<Blob> Create(
49-
Environment* env,
50-
const std::vector<BlobEntry> store,
51-
size_t length);
48+
static BaseObjectPtr<Blob> Create(Environment* env,
49+
const std::vector<BlobEntry>& store,
50+
size_t length);
5251

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

55-
const std::vector<BlobEntry> entries() const {
56-
return store_;
57-
}
54+
const std::vector<BlobEntry>& entries() const { return store_; }
5855

5956
void MemoryInfo(MemoryTracker* tracker) const override;
6057
SET_MEMORY_INFO_NAME(Blob)

0 commit comments

Comments
 (0)