Skip to content

Commit 3b938f6

Browse files
get rid of redundant calls to std::string constructor
1 parent c4eef94 commit 3b938f6

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

libs/libarchfpga/src/read_xml_arch_file.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ static std::pair<int, int> process_instance_string(pugi::xml_node Locations,
779779
size_t token_index = 0;
780780
t_token token = tokens[token_index];
781781

782-
if (token.type != e_token_type::STRING || std::string(token.data) != sub_tile.name) {
782+
if (token.type != e_token_type::STRING || token.data != sub_tile.name) {
783783
archfpga_throw(loc_data.filename_c_str(), loc_data.line(Locations),
784784
vtr::string_fmt("Wrong physical type name of the port: %s\n", pin_loc_string).c_str());
785785
}
@@ -2114,7 +2114,7 @@ static void process_fc(pugi::xml_node node,
21142114
static t_fc_override process_fc_override(pugi::xml_node node, const pugiutil::loc_data& loc_data) {
21152115
if (node.name() != std::string("fc_override")) {
21162116
archfpga_throw(loc_data.filename_c_str(), loc_data.line(node),
2117-
vtr::string_fmt("Unexpeted node of type '%s' (expected optional 'fc_override')",
2117+
vtr::string_fmt("Unexpected node of type '%s' (expected optional 'fc_override')",
21182118
node.name())
21192119
.c_str());
21202120
}
@@ -3366,12 +3366,11 @@ static void process_equivalent_site_custom_connection(pugi::xml_node Parent,
33663366

33673367
expect_only_attributes(cur_direct, {"from", "to"}, loc_data);
33683368

3369-
std::string from, to;
33703369
// `from` attribute is relative to the physical tile pins
3371-
from = std::string(get_attribute(cur_direct, "from", loc_data).value());
3370+
const std::string from = get_attribute(cur_direct, "from", loc_data).value();
33723371

33733372
// `to` attribute is relative to the logical block pins
3374-
to = std::string(get_attribute(cur_direct, "to", loc_data).value());
3373+
const std::string to = get_attribute(cur_direct, "to", loc_data).value();
33753374

33763375
auto from_pins = process_pin_string<t_sub_tile*>(cur_direct, sub_tile, from.c_str(), loc_data);
33773376
auto to_pins = process_pin_string<t_logical_block_type_ptr>(cur_direct, logical_block_type, to.c_str(), loc_data);
@@ -3820,7 +3819,7 @@ static std::vector<t_segment_inf> process_segments(pugi::xml_node parent,
38203819
/* Get segment name */
38213820
tmp = get_attribute(node, "name", loc_data, ReqOpt::OPTIONAL).as_string(nullptr);
38223821
if (tmp) {
3823-
segs[i].name = std::string(tmp);
3822+
segs[i].name = tmp;
38243823
} else {
38253824
/* if swich block is "custom", then you have to provide a name for segment */
38263825
if (switchblocklist_required) {
@@ -3832,7 +3831,7 @@ static std::vector<t_segment_inf> process_segments(pugi::xml_node parent,
38323831
ss << "unnamed_segment_" << i;
38333832
std::string dummy = ss.str();
38343833
tmp = dummy.c_str();
3835-
segs[i].name = std::string(tmp);
3834+
segs[i].name = tmp;
38363835
}
38373836

38383837
/* Get segment length */
@@ -4396,14 +4395,14 @@ static std::vector<t_arch_switch_inf> process_switches(pugi::xml_node Parent,
43964395

43974396
// Check for switch name collisions
43984397
for (int j = 0; j < i; ++j) {
4399-
if (0 == strcmp(switches[j].name.c_str(), switch_name)) {
4398+
if (switches[j].name == switch_name) {
44004399
archfpga_throw(loc_data.filename_c_str(), loc_data.line(node),
44014400
vtr::string_fmt("Two switches with the same name '%s' were found.\n",
44024401
switch_name)
44034402
.c_str());
44044403
}
44054404
}
4406-
arch_switch.name = std::string(switch_name);
4405+
arch_switch.name = switch_name;
44074406

44084407
/* Figure out the type of switch */
44094408
/* As noted above, due to their configuration of pass transistors feeding into a buffer,

vpr/src/base/read_netlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ ClusteredNetlist read_netlist(const char* net_file,
134134
auto msg = vtr::string_fmt(
135135
"Netlist was generated from a different architecture file"
136136
" (loaded architecture ID: %s, netlist file architecture ID: %s)",
137-
arch->architecture_id, arch_id.c_str());
137+
arch->architecture_id.c_str(), arch_id.c_str());
138138
if (verify_file_digests) {
139139
vpr_throw(VPR_ERROR_NET_F, netlist_file_name, loc_data.line(top), msg.c_str());
140140
} else {

0 commit comments

Comments
 (0)