Skip to content

Commit b0662ef

Browse files
committed
Added const reference params
1 parent f7de464 commit b0662ef

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

src/cpucounters.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4046,7 +4046,7 @@ void PCM::cleanupRDT(const bool silent)
40464046
if (!silent) std::cerr << " Freeing up all RMIDs\n";
40474047
}
40484048

4049-
void PCM::setOutput(const std::string filename, const bool cerrToo)
4049+
void PCM::setOutput(const std::string & filename, const bool cerrToo)
40504050
{
40514051
outfile = new std::ofstream(filename.c_str());
40524052
backup_ofile = std::cout.rdbuf();

src/cpucounters.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ class PCM_API PCM
675675
}
676676

677677
//! \brief Redirects output destination to provided file, instead of std::cout and std::cerr (optional)
678-
static void setOutput(const std::string filename, const bool cerrToo = false);
678+
static void setOutput(const std::string & filename, const bool cerrToo = false);
679679

680680
//! \brief Restores output, closes output file if opened
681681
void restoreOutput();

src/pcm-core.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ extern "C" {
120120
}
121121
}
122122

123-
void print_usage(const string progname)
123+
void print_usage(const string & progname)
124124
{
125125
cerr << "\n Usage: \n " << progname
126126
<< " --help | [delay] [options] [-- external_program [external_program_options]]\n";

src/pcm-iio.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,14 @@ void print_nameMap() {
180180
}
181181

182182

183-
string a_title (const string &init, const string &name) {
183+
string a_title(const string &init, const string &name) {
184184
char begin = init[0];
185185
string row = init;
186186
row += name;
187187
return row + begin;
188188
}
189189

190-
string a_data (string init, struct data d) {
190+
string a_data(const string &init, struct data d) {
191191
char begin = init[0];
192192
string row = init;
193193
string str_d = unit_format(d.value);
@@ -198,7 +198,7 @@ string a_data (string init, struct data d) {
198198
return row + begin;
199199
}
200200

201-
string build_line(string init, string name, bool last_char = true, char this_char = '_')
201+
string build_line(const string &init, const string &name, bool last_char = true, char this_char = '_')
202202
{
203203
char begin = init[0];
204204
string row = init;
@@ -209,12 +209,12 @@ string build_line(string init, string name, bool last_char = true, char this_cha
209209
}
210210

211211

212-
string a_header_footer (string init, string name)
212+
string a_header_footer(const string &init, const string &name)
213213
{
214214
return build_line(init, name);
215215
}
216216

217-
vector<string> combine_stack_name_and_counter_names(string stack_name)
217+
vector<string> combine_stack_name_and_counter_names(const string &stack_name)
218218
{
219219

220220
vector<string> v;
@@ -223,7 +223,7 @@ vector<string> combine_stack_name_and_counter_names(string stack_name)
223223
for (std::map<string,std::pair<h_id,std::map<string,v_id>>>::const_iterator iunit = nameMap.begin(); iunit != nameMap.end(); ++iunit) {
224224
string h_name = iunit->first;
225225
int h_id = (iunit->second).first;
226-
tmp[h_id] = h_name;
226+
tmp[h_id] = std::move(h_name);
227227
//cout << "h_id:" << h_id << " name:" << h_name << "\n";
228228
}
229229
//XXX: How to simplify and just combine tmp & v?
@@ -350,7 +350,7 @@ vector<string> build_display(vector<struct iio_stacks_on_socket>& iios, vector<s
350350

351351
std::string build_csv_row(const std::vector<std::string>& chunks, const std::string& delimiter)
352352
{
353-
return std::accumulate(chunks.begin(), chunks.end(), std::string(""),
353+
return std::accumulate(chunks.begin(), chunks.end(), std::string(),
354354
[delimiter](const string &left, const string &right){
355355
return left.empty() ? right : left + delimiter + right;
356356
});
@@ -544,7 +544,7 @@ bool IPlatformMapping10Nm::getSadIdRootBusMap(uint32_t socket_id, std::map<uint8
544544

545545
if ((sad_ctrl_cfg & 0xf) == socket_id) {
546546
uint8_t sid = (sad_ctrl_cfg >> 4) & 0x7;
547-
sad_id_bus_map.insert(std::pair<uint8_t, uint8_t>(sid, (uint8_t)bus));
547+
sad_id_bus_map.emplace(sid, (uint8_t)bus);
548548
}
549549
}
550550
}
@@ -920,19 +920,19 @@ vector<struct counter> load_events(PCM * m, const char* fn)
920920
/* Ignore anyline with # */
921921
//TODO: substring until #, if len == 0, skip, else parse normally
922922
pccr->set_ccr_value(0);
923-
if (line.find("#") != std::string::npos)
923+
if (line.find('#') != std::string::npos)
924924
continue;
925925
/* If line does not have any deliminator, we ignore it as well */
926-
if (line.find("=") == std::string::npos)
926+
if (line.find('=') == std::string::npos)
927927
continue;
928928
std::istringstream iss(line);
929929
string h_name, v_name;
930930
while (std::getline(iss, item, ',')) {
931931
std::string key, value;
932932
uint64 numValue;
933933
/* assume the token has the format <key>=<value> */
934-
key = item.substr(0,item.find("="));
935-
value = item.substr(item.find("=")+1);
934+
key = item.substr(0,item.find('='));
935+
value = item.substr(item.find('=')+1);
936936
istringstream iss2(value);
937937
iss2 >> setbase(0) >> numValue;
938938

@@ -1119,11 +1119,11 @@ bool extract_argument_value(const char* arg, std::initializer_list<const char*>
11191119
const auto arg_name_len = strlen(arg_name);
11201120
if (arg_len > arg_name_len && strncmp(arg, arg_name, arg_name_len) == 0 && arg[arg_name_len] == '=') {
11211121
value = arg + arg_name_len + 1;
1122-
const auto last_pos = value.find_last_not_of("\"");
1122+
const auto last_pos = value.find_last_not_of('\"');
11231123
if (last_pos != string::npos) {
11241124
value.erase(last_pos + 1);
11251125
}
1126-
const auto first_pos = value.find_first_not_of("\"");
1126+
const auto first_pos = value.find_first_not_of('\"');
11271127
if (first_pos != string::npos) {
11281128
value.erase(0, first_pos);
11291129
}

src/pcm-memory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ bool anyPmem(const ServerUncoreMemoryMetrics & metrics)
8181

8282
bool skipInactiveChannels = true;
8383

84-
void print_help(const string prog_name)
84+
void print_help(const string & progname)
8585
{
8686
cerr << "\n Usage: \n " << progname
8787
<< " --help | [delay] [options] [-- external_program [external_program_options]]\n";

src/pcm.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ double getAverageUncoreFrequencyGhz(const UncoreStateType& before, const UncoreS
7979
return getAverageUncoreFrequency(before, after) / 1e9;
8080
}
8181

82-
void print_help(const string prog_name)
82+
void print_help(const string & progname)
8383
{
8484
cerr << "\n Usage: \n " << progname
8585
<< " --help | [delay] [options] [-- external_program [external_program_options]]\n";
@@ -554,13 +554,13 @@ void print_basic_metrics_csv_header(const PCM * m)
554554
cout << "Frontend_bound(%),Bad_Speculation(%),Backend_Bound(%),Retiring(%),";
555555
}
556556

557-
void print_csv_header_helper(string header, int count=1){
557+
void print_csv_header_helper(const string & header, int count=1){
558558
for(int i = 0; i < count; i++){
559559
cout << header << ",";
560560
}
561561
}
562562

563-
void print_basic_metrics_csv_semicolons(const PCM * m, string header)
563+
void print_basic_metrics_csv_semicolons(const PCM * m, const string & header)
564564
{
565565
print_csv_header_helper(header, 3); // EXEC;IPC;FREQ;
566566
if (m->isActiveRelativeFrequencyAvailable())

0 commit comments

Comments
 (0)