Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 25ddbc9

Browse filesBrowse files
gengjiawenrvagg
authored andcommitted
src: apply clang-tidy rule performance-unnecessary-value-param
PR-URL: #26042 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 8fac54a commit 25ddbc9
Copy full SHA for 25ddbc9

File tree

Expand file treeCollapse file tree

10 files changed

+25
-19
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

10 files changed

+25
-19
lines changed
Open diff view settings
Collapse file

‎src/env-inl.h‎

Copy file name to clipboardExpand all lines: src/env-inl.h
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#include <stddef.h>
3838
#include <stdint.h>
3939

40+
#include <utility>
41+
4042
namespace node {
4143

4244
inline v8::Isolate* IsolateData::isolate() const {
@@ -395,7 +397,7 @@ inline uv_loop_t* Environment::event_loop() const {
395397
inline void Environment::TryLoadAddon(
396398
const char* filename,
397399
int flags,
398-
std::function<bool(binding::DLib*)> was_loaded) {
400+
const std::function<bool(binding::DLib*)>& was_loaded) {
399401
loaded_addons_.emplace_back(filename, flags);
400402
if (!was_loaded(&loaded_addons_.back())) {
401403
loaded_addons_.pop_back();
@@ -597,7 +599,7 @@ inline std::shared_ptr<PerIsolateOptions> IsolateData::options() {
597599

598600
inline void IsolateData::set_options(
599601
std::shared_ptr<PerIsolateOptions> options) {
600-
options_ = options;
602+
options_ = std::move(options);
601603
}
602604

603605
void Environment::CreateImmediate(native_immediate_callback cb,
Collapse file

‎src/env.h‎

Copy file name to clipboardExpand all lines: src/env.h
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,10 @@ class Environment {
661661

662662
inline v8::Isolate* isolate() const;
663663
inline uv_loop_t* event_loop() const;
664-
inline void TryLoadAddon(const char* filename,
665-
int flags,
666-
std::function<bool(binding::DLib*)> was_loaded);
664+
inline void TryLoadAddon(
665+
const char* filename,
666+
int flags,
667+
const std::function<bool(binding::DLib*)>& was_loaded);
667668

668669
static inline Environment* from_timer_handle(uv_timer_t* handle);
669670
inline uv_timer_t* timer_handle();
Collapse file

‎src/node_crypto.cc‎

Copy file name to clipboardExpand all lines: src/node_crypto.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2685,7 +2685,7 @@ static ParsePublicKeyResult TryParsePublicKey(
26852685
const BIOPointer& bp,
26862686
const char* name,
26872687
// NOLINTNEXTLINE(runtime/int)
2688-
std::function<EVP_PKEY*(const unsigned char** p, long l)> parse) {
2688+
const std::function<EVP_PKEY*(const unsigned char** p, long l)>& parse) {
26892689
unsigned char* der_data;
26902690
long der_len; // NOLINT(runtime/int)
26912691

Collapse file

‎src/node_messaging.cc‎

Copy file name to clipboardExpand all lines: src/node_messaging.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ MaybeLocal<Value> Message::Deserialize(Environment* env,
148148
}
149149

150150
void Message::AddSharedArrayBuffer(
151-
SharedArrayBufferMetadataReference reference) {
151+
const SharedArrayBufferMetadataReference& reference) {
152152
shared_array_buffers_.push_back(reference);
153153
}
154154

Collapse file

‎src/node_messaging.h‎

Copy file name to clipboardExpand all lines: src/node_messaging.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Message : public MemoryRetainer {
4343

4444
// Internal method of Message that is called when a new SharedArrayBuffer
4545
// object is encountered in the incoming value's structure.
46-
void AddSharedArrayBuffer(SharedArrayBufferMetadataReference ref);
46+
void AddSharedArrayBuffer(const SharedArrayBufferMetadataReference& ref);
4747
// Internal method of Message that is called once serialization finishes
4848
// and that transfers ownership of `data` to this message.
4949
void AddMessagePort(std::unique_ptr<MessagePortData>&& data);
Collapse file

‎src/node_perf.cc‎

Copy file name to clipboardExpand all lines: src/node_perf.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void ClearMark(const FunctionCallbackInfo<Value>& args) {
181181
}
182182
}
183183

184-
inline uint64_t GetPerformanceMark(Environment* env, std::string name) {
184+
inline uint64_t GetPerformanceMark(Environment* env, const std::string& name) {
185185
auto marks = env->performance_marks();
186186
auto res = marks->find(name);
187187
return res != marks->end() ? res->second : 0;
Collapse file

‎src/node_url.h‎

Copy file name to clipboardExpand all lines: src/node_url.h
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,16 @@ class URL {
109109
}
110110
}
111111

112-
explicit URL(std::string input) :
112+
explicit URL(const std::string& input) :
113113
URL(input.c_str(), input.length()) {}
114114

115-
URL(std::string input, const URL* base) :
115+
URL(const std::string& input, const URL* base) :
116116
URL(input.c_str(), input.length(), base) {}
117117

118-
URL(std::string input, const URL& base) :
118+
URL(const std::string& input, const URL& base) :
119119
URL(input.c_str(), input.length(), &base) {}
120120

121-
URL(std::string input, std::string base) :
121+
URL(const std::string& input, const std::string& base) :
122122
URL(input.c_str(), input.length(), base.c_str(), base.length()) {}
123123

124124
int32_t flags() {
Collapse file

‎src/sharedarraybuffer_metadata.cc‎

Copy file name to clipboardExpand all lines: src/sharedarraybuffer_metadata.cc
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#include "sharedarraybuffer_metadata.h"
2+
3+
#include <utility>
24
#include "base_object.h"
35
#include "base_object-inl.h"
46
#include "node_errors.h"
@@ -43,7 +45,7 @@ class SABLifetimePartner : public BaseObject {
4345
Local<Object> obj,
4446
SharedArrayBufferMetadataReference r)
4547
: BaseObject(env, obj),
46-
reference(r) {
48+
reference(std::move(r)) {
4749
MakeWeak();
4850
}
4951

Collapse file

‎src/util.h‎

Copy file name to clipboardExpand all lines: src/util.h
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <string>
4141
#include <array>
4242
#include <unordered_map>
43+
#include <utility>
4344

4445
namespace node {
4546

@@ -450,7 +451,7 @@ template <typename T> inline void USE(T&&) {}
450451
struct OnScopeLeave {
451452
std::function<void()> fn_;
452453

453-
explicit OnScopeLeave(std::function<void()> fn) : fn_(fn) {}
454+
explicit OnScopeLeave(std::function<void()> fn) : fn_(std::move(fn)) {}
454455
~OnScopeLeave() { fn_(); }
455456
};
456457

Collapse file

‎test/cctest/test_inspector_socket_server.cc‎

Copy file name to clipboardExpand all lines: test/cctest/test_inspector_socket_server.cc
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class SocketWrapper {
9292
connected_(false),
9393
sending_(false) { }
9494

95-
void Connect(std::string host, int port, bool v6 = false) {
95+
void Connect(const std::string& host, int port, bool v6 = false) {
9696
closed_ = false;
9797
connection_failed_ = false;
9898
connected_ = false;
@@ -114,7 +114,7 @@ class SocketWrapper {
114114
ReadCallback);
115115
}
116116

117-
void ExpectFailureToConnect(std::string host, int port) {
117+
void ExpectFailureToConnect(const std::string& host, int port) {
118118
connected_ = false;
119119
connection_failed_ = false;
120120
closed_ = false;
@@ -243,7 +243,7 @@ class ServerHolder {
243243
: ServerHolder(has_targets, loop, HOST, port, nullptr) { }
244244

245245
ServerHolder(bool has_targets, uv_loop_t* loop,
246-
const std::string host, int port, FILE* out);
246+
const std::string& host, int port, FILE* out);
247247

248248
InspectorSocketServer* operator->() {
249249
return server_.get();
@@ -350,7 +350,7 @@ class TestSocketServerDelegate : public SocketServerDelegate {
350350
};
351351

352352
ServerHolder::ServerHolder(bool has_targets, uv_loop_t* loop,
353-
const std::string host, int port, FILE* out) {
353+
const std::string& host, int port, FILE* out) {
354354
std::vector<std::string> targets;
355355
if (has_targets)
356356
targets = { MAIN_TARGET_ID };

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.