init: fix clang-tidy performance issues
Test: boot, init unit tests Change-Id: Iccf34d2fedfa543dd9f29e010cbb6d8fe9cf5983
This commit is contained in:
parent
d543c8ca11
commit
7c1d87e490
10 changed files with 18 additions and 18 deletions
|
@ -95,7 +95,7 @@ Result<void> Action::AddCommand(std::vector<std::string>&& args, int line) {
|
|||
}
|
||||
|
||||
void Action::AddCommand(BuiltinFunction f, std::vector<std::string>&& args, int line) {
|
||||
commands_.emplace_back(f, false, std::move(args), line);
|
||||
commands_.emplace_back(std::move(f), false, std::move(args), line);
|
||||
}
|
||||
|
||||
std::size_t Action::NumCommands() const {
|
||||
|
|
|
@ -47,7 +47,7 @@ void ActionManager::QueueAllPropertyActions() {
|
|||
void ActionManager::QueueBuiltinAction(BuiltinFunction func, const std::string& name) {
|
||||
auto action = std::make_unique<Action>(true, nullptr, "<Builtin Action>", 0, name,
|
||||
std::map<std::string, std::string>{});
|
||||
action->AddCommand(func, {name}, 0);
|
||||
action->AddCommand(std::move(func), {name}, 0);
|
||||
|
||||
event_queue_.emplace(action.get());
|
||||
actions_.emplace_back(std::move(action));
|
||||
|
|
|
@ -84,9 +84,9 @@ class Subsystem {
|
|||
};
|
||||
|
||||
Subsystem() {}
|
||||
Subsystem(const std::string& name) : name_(name) {}
|
||||
Subsystem(const std::string& name, DevnameSource source, const std::string& dir_name)
|
||||
: name_(name), devname_source_(source), dir_name_(dir_name) {}
|
||||
Subsystem(std::string name) : name_(std::move(name)) {}
|
||||
Subsystem(std::string name, DevnameSource source, std::string dir_name)
|
||||
: name_(std::move(name)), devname_source_(source), dir_name_(std::move(dir_name)) {}
|
||||
|
||||
// Returns the full path for a uevent of a device that is a member of this subsystem,
|
||||
// according to the rules parsed from ueventd.rc
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace init {
|
|||
class DeviceHandlerTester {
|
||||
public:
|
||||
void TestGetSymlinks(const std::string& platform_device, const Uevent& uevent,
|
||||
const std::vector<std::string> expected_links) {
|
||||
const std::vector<std::string>& expected_links) {
|
||||
TemporaryDir fake_sys_root;
|
||||
device_handler_.sysfs_mount_point_ = fake_sys_root.path;
|
||||
|
||||
|
|
|
@ -285,7 +285,7 @@ void Keychords::Register(const std::vector<int>& keycodes) {
|
|||
|
||||
void Keychords::Start(Epoll* epoll, std::function<void(const std::vector<int>&)> handler) {
|
||||
epoll_ = epoll;
|
||||
handler_ = handler;
|
||||
handler_ = std::move(handler);
|
||||
if (entries_.size()) GeteventOpenDevice();
|
||||
}
|
||||
|
||||
|
|
|
@ -140,11 +140,11 @@ void MountHandler::MountHandlerFunction() {
|
|||
}
|
||||
}
|
||||
free(buf);
|
||||
for (auto entry : untouched) {
|
||||
for (auto& entry : untouched) {
|
||||
SetMountProperty(entry, false);
|
||||
mounts_.erase(entry);
|
||||
}
|
||||
for (auto entry : touched) {
|
||||
for (auto& entry : touched) {
|
||||
SetMountProperty(entry, true);
|
||||
mounts_.emplace(std::move(entry));
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ void Parser::AddSectionParser(const std::string& name, std::unique_ptr<SectionPa
|
|||
}
|
||||
|
||||
void Parser::AddSingleLineParser(const std::string& prefix, LineCallback callback) {
|
||||
line_callbacks_.emplace_back(prefix, callback);
|
||||
line_callbacks_.emplace_back(prefix, std::move(callback));
|
||||
}
|
||||
|
||||
void Parser::ParseData(const std::string& filename, std::string* data) {
|
||||
|
|
|
@ -83,7 +83,7 @@ Result<void> MixHwrngIntoLinuxRngAction(const BuiltinArguments&) {
|
|||
return {};
|
||||
}
|
||||
|
||||
static bool SetHighestAvailableOptionValue(std::string path, int min, int max) {
|
||||
static bool SetHighestAvailableOptionValue(const std::string& path, int min, int max) {
|
||||
std::ifstream inf(path, std::fstream::in);
|
||||
if (!inf) {
|
||||
LOG(ERROR) << "Cannot open for reading: " << path;
|
||||
|
|
|
@ -30,17 +30,17 @@ class TestFunctionMap : public KeywordFunctionMap {
|
|||
public:
|
||||
// Helper for argument-less functions
|
||||
using BuiltinFunctionNoArgs = std::function<void(void)>;
|
||||
void Add(const std::string& name, const BuiltinFunctionNoArgs function) {
|
||||
Add(name, 0, 0, false, [function](const BuiltinArguments&) {
|
||||
function();
|
||||
void Add(const std::string& name, BuiltinFunctionNoArgs function) {
|
||||
Add(name, 0, 0, false, [f = std::move(function)](const BuiltinArguments&) {
|
||||
f();
|
||||
return Result<void>{};
|
||||
});
|
||||
}
|
||||
|
||||
void Add(const std::string& name, std::size_t min_parameters, std::size_t max_parameters,
|
||||
bool run_in_subcontext, const BuiltinFunction function) {
|
||||
builtin_functions_[name] =
|
||||
make_tuple(min_parameters, max_parameters, make_pair(run_in_subcontext, function));
|
||||
bool run_in_subcontext, BuiltinFunction function) {
|
||||
builtin_functions_[name] = make_tuple(min_parameters, max_parameters,
|
||||
make_pair(run_in_subcontext, std::move(function)));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -146,7 +146,7 @@ void ColdBoot::UeventHandlerMain(unsigned int process_num, unsigned int total_pr
|
|||
|
||||
void ColdBoot::RegenerateUevents() {
|
||||
uevent_listener_.RegenerateUevents([this](const Uevent& uevent) {
|
||||
uevent_queue_.emplace_back(std::move(uevent));
|
||||
uevent_queue_.emplace_back(uevent);
|
||||
return ListenerAction::kContinue;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue