Skip to content

Commit 25ddbc9

Browse 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

10 files changed

+25
-19
lines changed

src/env-inl.h

+4-2
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,

src/env.h

+4-3
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();

src/node_crypto.cc

+1-1
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

src/node_messaging.cc

+1-1
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

src/node_messaging.h

+1-1
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);

src/node_perf.cc

+1-1
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;

src/node_url.h

+4-4
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() {

src/sharedarraybuffer_metadata.cc

+3-1
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

src/util.h

+2-1
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

test/cctest/test_inspector_socket_server.cc

+4-4
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)