* Declare explicit conversion constructors.
* Use const reference type for parameter to avoid unnecessary copy.
Bug:
28341362
Bug:
30407689
Change-Id: Ia95a041125703ecbfac128709fd6ea0591df2103
Test: build with WITH_TIDY=1
}
using Sorter = std::function<void(std::vector<TaskStatistics>&)>;
-static Sorter GetSorter(const std::string field) {
+static Sorter GetSorter(const std::string& field) {
// Generic comparator
static auto comparator = [](auto& lhs, auto& rhs, auto field, bool ascending) -> bool {
auto a = (lhs.*field)();
#include "tasklist.h"
template<typename Func>
-static bool ScanPidsInDir(std::string name, Func f) {
+static bool ScanPidsInDir(const std::string& name, Func f) {
std::unique_ptr<DIR, decltype(&closedir)> dir(opendir(name.c_str()), closedir);
if (!dir) {
return false;
class TaskStatistics {
public:
- TaskStatistics(const taskstats&);
+ explicit TaskStatistics(const taskstats&);
TaskStatistics() = default;
TaskStatistics(const TaskStatistics&) = default;
void AddPidToTgid(const TaskStatistics&);