Skip to content

Commit

Permalink
add/remove const& where needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Tessa Todorowski committed Aug 23, 2024
1 parent 4c11c7b commit a729250
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions include/lo2s/perf/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class Event
{
public:
Event([[maybe_unused]] uint64_t addr, bool enable_on_exec = false);
Event(std::string name, perf_type_id type, std::uint64_t config, std::uint64_t config1 = 0);
Event(const std::string& name, perf_type_id type, std::uint64_t config,
std::uint64_t config1 = 0);
Event();

/**
Expand Down Expand Up @@ -116,13 +117,12 @@ class Event
scale_ = scale;
}

void set_unit(std::string unit)
void set_unit(const std::string& unit)
{
unit_ = unit;
}

void set_clock_attrs([[maybe_unused]] const bool& use_clockid,
[[maybe_unused]] const clockid_t& clockid)
void set_clock_attrs([[maybe_unused]] bool use_clockid, [[maybe_unused]] clockid_t clockid)
{
#ifndef USE_HW_BREAKPOINT_COMPAT
attr_.use_clockid = use_clockid;
Expand All @@ -132,13 +132,13 @@ class Event

// When we poll on the fd given by perf_event_open, wakeup, when our buffer is 80% full
// Default behaviour is to wakeup on every event, which is horrible performance wise
void set_watermark(const size_t& mmap_pages)
void set_watermark(size_t mmap_pages)
{
attr_.watermark = 1;
attr_.wakeup_watermark = static_cast<uint32_t>(0.8 * mmap_pages * sysconf(_SC_PAGESIZE));
}

void set_exclude_kernel(const bool& exclude_kernel)
void set_exclude_kernel(bool exclude_kernel)
{
attr_.exclude_kernel = exclude_kernel;
}
Expand Down
8 changes: 4 additions & 4 deletions include/lo2s/perf/event_provider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ class EventProvider
static Event create_time_event(uint64_t local_time);
static Event create_raw_event(const std::string& name, perf_type_id type, std::uint64_t config,
std::uint64_t config1 = 0);
static SysfsEvent create_sampling_event(const bool& enable_on_exec);
static SysfsEvent create_sampling_event(bool enable_on_exec);
static SysfsEvent create_raw_sysfs_event(const std::string& name);
static SysfsEvent create_sysfs_event(const std::string& name);
static tracepoint::TracepointEvent
create_raw_tracepoint_event(const std::string& name, const bool& enable_on_exec = false);
static tracepoint::TracepointEvent create_raw_tracepoint_event(const std::string& name,
bool enable_on_exec = false);
static tracepoint::TracepointEvent create_tracepoint_event(const std::string& name,
const bool& enable_on_exec = false);
bool enable_on_exec = false);

class InvalidEvent : public std::runtime_error
{
Expand Down
6 changes: 3 additions & 3 deletions src/perf/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ template <class... Ts>
overloaded(Ts...) -> overloaded<Ts...>;

template <typename T>
T read_file_or_else(std::string filename, T or_else)
T read_file_or_else(const std::string& filename, T or_else)
{
T val;
std::ifstream stream(filename);
Expand All @@ -83,7 +83,6 @@ static std::uint64_t parse_bitmask(const std::string& format)

static const std::regex bit_mask_regex(R"((\d+)?(?:-(\d+)))");
const std::sregex_iterator end;
std::smatch bit_mask_match;
for (std::sregex_iterator i = { format.begin(), format.end(), bit_mask_regex }; i != end; ++i)
{
const auto& match = *i;
Expand Down Expand Up @@ -161,7 +160,8 @@ Event::Event([[maybe_unused]] uint64_t addr, bool enable_on_exec)
#endif
}

Event::Event(std::string name, perf_type_id type, std::uint64_t config, std::uint64_t config1)
Event::Event(const std::string& name, perf_type_id type, std::uint64_t config,
std::uint64_t config1)
: name_(name)
{
memset(&attr_, 0, sizeof(attr_));
Expand Down
6 changes: 3 additions & 3 deletions src/perf/event_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ std::vector<Event> EventProvider::get_predefined_events()
}

tracepoint::TracepointEvent EventProvider::create_tracepoint_event(const std::string& name,
const bool& enable_on_exec)
bool enable_on_exec)
{
tracepoint::TracepointEvent event(name, enable_on_exec);
event.set_sample_period(0);
Expand All @@ -379,7 +379,7 @@ tracepoint::TracepointEvent EventProvider::create_tracepoint_event(const std::st
}

tracepoint::TracepointEvent EventProvider::create_raw_tracepoint_event(const std::string& name,
const bool& enable_on_exec)
bool enable_on_exec)
{
tracepoint::TracepointEvent event(name, enable_on_exec);
event.set_sample_period(0);
Expand Down Expand Up @@ -411,7 +411,7 @@ Event EventProvider::create_raw_event(const std::string& name, perf_type_id type
return event;
}

SysfsEvent EventProvider::create_sampling_event(const bool& enable_on_exec)
SysfsEvent EventProvider::create_sampling_event(bool enable_on_exec)
{
SysfsEvent event(config().sampling_event, enable_on_exec);
apply_config_attrs(event);
Expand Down

0 comments on commit a729250

Please sign in to comment.