Skip to content

Commit

Permalink
src: apply clang-tidy rule performance-unnecessary-value-param
Browse files Browse the repository at this point in the history
PR-URL: #26042
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
gengjiawen authored and danbev committed Feb 19, 2019
1 parent b200a46 commit 8375c70
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 19 deletions.
6 changes: 4 additions & 2 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include <stddef.h>
#include <stdint.h>

#include <utility>

namespace node {

inline v8::Isolate* IsolateData::isolate() const {
Expand Down Expand Up @@ -395,7 +397,7 @@ inline uv_loop_t* Environment::event_loop() const {
inline void Environment::TryLoadAddon(
const char* filename,
int flags,
std::function<bool(binding::DLib*)> was_loaded) {
const std::function<bool(binding::DLib*)>& was_loaded) {
loaded_addons_.emplace_back(filename, flags);
if (!was_loaded(&loaded_addons_.back())) {
loaded_addons_.pop_back();
Expand Down Expand Up @@ -597,7 +599,7 @@ inline std::shared_ptr<PerIsolateOptions> IsolateData::options() {

inline void IsolateData::set_options(
std::shared_ptr<PerIsolateOptions> options) {
options_ = options;
options_ = std::move(options);
}

void Environment::CreateImmediate(native_immediate_callback cb,
Expand Down
7 changes: 4 additions & 3 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,10 @@ class Environment {

inline v8::Isolate* isolate() const;
inline uv_loop_t* event_loop() const;
inline void TryLoadAddon(const char* filename,
int flags,
std::function<bool(binding::DLib*)> was_loaded);
inline void TryLoadAddon(
const char* filename,
int flags,
const std::function<bool(binding::DLib*)>& was_loaded);

static inline Environment* from_timer_handle(uv_timer_t* handle);
inline uv_timer_t* timer_handle();
Expand Down
2 changes: 1 addition & 1 deletion src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2712,7 +2712,7 @@ static ParsePublicKeyResult TryParsePublicKey(
const BIOPointer& bp,
const char* name,
// NOLINTNEXTLINE(runtime/int)
std::function<EVP_PKEY*(const unsigned char** p, long l)> parse) {
const std::function<EVP_PKEY*(const unsigned char** p, long l)>& parse) {
unsigned char* der_data;
long der_len; // NOLINT(runtime/int)

Expand Down
2 changes: 1 addition & 1 deletion src/node_messaging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ MaybeLocal<Value> Message::Deserialize(Environment* env,
}

void Message::AddSharedArrayBuffer(
SharedArrayBufferMetadataReference reference) {
const SharedArrayBufferMetadataReference& reference) {
shared_array_buffers_.push_back(reference);
}

Expand Down
2 changes: 1 addition & 1 deletion src/node_messaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Message : public MemoryRetainer {

// Internal method of Message that is called when a new SharedArrayBuffer
// object is encountered in the incoming value's structure.
void AddSharedArrayBuffer(SharedArrayBufferMetadataReference ref);
void AddSharedArrayBuffer(const SharedArrayBufferMetadataReference& ref);
// Internal method of Message that is called once serialization finishes
// and that transfers ownership of `data` to this message.
void AddMessagePort(std::unique_ptr<MessagePortData>&& data);
Expand Down
2 changes: 1 addition & 1 deletion src/node_perf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void ClearMark(const FunctionCallbackInfo<Value>& args) {
}
}

inline uint64_t GetPerformanceMark(Environment* env, std::string name) {
inline uint64_t GetPerformanceMark(Environment* env, const std::string& name) {
auto marks = env->performance_marks();
auto res = marks->find(name);
return res != marks->end() ? res->second : 0;
Expand Down
8 changes: 4 additions & 4 deletions src/node_url.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ class URL {
}
}

explicit URL(std::string input) :
explicit URL(const std::string& input) :
URL(input.c_str(), input.length()) {}

URL(std::string input, const URL* base) :
URL(const std::string& input, const URL* base) :
URL(input.c_str(), input.length(), base) {}

URL(std::string input, const URL& base) :
URL(const std::string& input, const URL& base) :
URL(input.c_str(), input.length(), &base) {}

URL(std::string input, std::string base) :
URL(const std::string& input, const std::string& base) :
URL(input.c_str(), input.length(), base.c_str(), base.length()) {}

int32_t flags() {
Expand Down
4 changes: 3 additions & 1 deletion src/sharedarraybuffer_metadata.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "sharedarraybuffer_metadata.h"

#include <utility>
#include "base_object.h"
#include "base_object-inl.h"
#include "node_errors.h"
Expand Down Expand Up @@ -43,7 +45,7 @@ class SABLifetimePartner : public BaseObject {
Local<Object> obj,
SharedArrayBufferMetadataReference r)
: BaseObject(env, obj),
reference(r) {
reference(std::move(r)) {
MakeWeak();
}

Expand Down
3 changes: 2 additions & 1 deletion src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <string>
#include <array>
#include <unordered_map>
#include <utility>

namespace node {

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

explicit OnScopeLeave(std::function<void()> fn) : fn_(fn) {}
explicit OnScopeLeave(std::function<void()> fn) : fn_(std::move(fn)) {}
~OnScopeLeave() { fn_(); }
};

Expand Down
8 changes: 4 additions & 4 deletions test/cctest/test_inspector_socket_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class SocketWrapper {
connected_(false),
sending_(false) { }

void Connect(std::string host, int port, bool v6 = false) {
void Connect(const std::string& host, int port, bool v6 = false) {
closed_ = false;
connection_failed_ = false;
connected_ = false;
Expand All @@ -114,7 +114,7 @@ class SocketWrapper {
ReadCallback);
}

void ExpectFailureToConnect(std::string host, int port) {
void ExpectFailureToConnect(const std::string& host, int port) {
connected_ = false;
connection_failed_ = false;
closed_ = false;
Expand Down Expand Up @@ -243,7 +243,7 @@ class ServerHolder {
: ServerHolder(has_targets, loop, HOST, port, nullptr) { }

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

InspectorSocketServer* operator->() {
return server_.get();
Expand Down Expand Up @@ -350,7 +350,7 @@ class TestSocketServerDelegate : public SocketServerDelegate {
};

ServerHolder::ServerHolder(bool has_targets, uv_loop_t* loop,
const std::string host, int port, FILE* out) {
const std::string& host, int port, FILE* out) {
std::vector<std::string> targets;
if (has_targets)
targets = { MAIN_TARGET_ID };
Expand Down

0 comments on commit 8375c70

Please sign in to comment.