Skip to content

Commit 2fba443

Browse files
TonCherAmiNBonaparte
authored andcommitted
fix(cpu): Replace %percentage-cores% normally (#1282)
1 parent a881d49 commit 2fba443

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

src/modules/cpu.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@ namespace modules {
3434
m_rampload_core = load_ramp(m_conf, name(), TAG_RAMP_LOAD_PER_CORE);
3535
}
3636
if (m_formatter->has(TAG_LABEL)) {
37-
// Update the label parameter and replace the %percentag-cores% token with the individual core tokens
38-
string key{&TAG_LABEL[1], strlen(TAG_LABEL) - 2};
39-
auto label = m_conf.get<string>(name(), key, "%percentage%%");
40-
vector<string> cores;
41-
for (size_t i = 1; i <= m_cputimes.size(); i++) {
42-
cores.emplace_back("%percentage-core" + to_string(i) + "%%");
43-
}
44-
label = string_util::replace_all(label, "%percentage-cores%", string_util::join(cores, " "));
45-
const_cast<config&>(m_conf).set(name(), key, move(label));
46-
4737
m_label = load_optional_label(m_conf, name(), TAG_LABEL, "%percentage%%");
4838
}
4939
}
@@ -77,6 +67,7 @@ namespace modules {
7767
if (m_label) {
7868
m_label->reset_tokens();
7969
m_label->replace_token("%percentage%", to_string(static_cast<int>(m_total + 0.5)));
70+
m_label->replace_token("%percentage-cores%", string_util::join(percentage_cores, "% ") + "%");
8071

8172
for (size_t i = 0; i < percentage_cores.size(); i++) {
8273
m_label->replace_token("%percentage-core" + to_string(i + 1) + "%", percentage_cores[i]);

0 commit comments

Comments
 (0)