Skip to content

Commit 803cd32

Browse files
remove calls to unnecessary calls to c_str()
1 parent 02b8ade commit 803cd32

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

vpr/src/draw/draw_basic.cpp

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,16 @@ void draw_place(ezgl::renderer* g) {
158158
if (draw_state->draw_block_text) {
159159
// Draw text if the space has parts of the netlist
160160
if (bnum) {
161-
std::string name = cluster_ctx.clb_nlist.block_name(bnum) + vtr::string_fmt(" (#%zu)", size_t(bnum));
162-
163-
g->draw_text(center, name.c_str(), abs_clb_bbox.width(), abs_clb_bbox.height());
161+
const std::string name = cluster_ctx.clb_nlist.block_name(bnum) + vtr::string_fmt(" (#%zu)", size_t(bnum));
162+
g->draw_text(center, name, abs_clb_bbox.width(), abs_clb_bbox.height());
164163
}
165164

166165
// Draw text for block type so that user knows what block
167166
std::string block_type_loc = type->name;
168167
block_type_loc += vtr::string_fmt(" (%d,%d)", i, j);
169168

170169
g->draw_text(center - ezgl::point2d(0, abs_clb_bbox.height() / 4),
171-
block_type_loc.c_str(), abs_clb_bbox.width(), abs_clb_bbox.height());
170+
block_type_loc, abs_clb_bbox.width(), abs_clb_bbox.height());
172171
}
173172
}
174173
}
@@ -849,14 +848,12 @@ void draw_routing_util(ezgl::renderer* g) {
849848
if (draw_state->show_routing_util
850849
== DRAW_ROUTING_UTIL_WITH_VALUE) {
851850
g->draw_text(bb.center(),
852-
vtr::string_fmt("%.2f", chanx_util).c_str(),
851+
vtr::string_fmt("%.2f", chanx_util),
853852
bb.width(), bb.height());
854853
} else if (draw_state->show_routing_util
855854
== DRAW_ROUTING_UTIL_WITH_FORMULA) {
856855
g->draw_text(bb.center(),
857-
vtr::string_fmt("%.2f = %.0f / %.0f", chanx_util,
858-
chanx_usage[x][y], chanx_avail[x][y])
859-
.c_str(),
856+
vtr::string_fmt("%.2f = %.0f / %.0f", chanx_util, chanx_usage[x][y], chanx_avail[x][y]),
860857
bb.width(), bb.height());
861858
}
862859

@@ -883,14 +880,12 @@ void draw_routing_util(ezgl::renderer* g) {
883880
if (draw_state->show_routing_util
884881
== DRAW_ROUTING_UTIL_WITH_VALUE) {
885882
g->draw_text(bb.center(),
886-
vtr::string_fmt("%.2f", chany_util).c_str(),
883+
vtr::string_fmt("%.2f", chany_util),
887884
bb.width(), bb.height());
888885
} else if (draw_state->show_routing_util
889886
== DRAW_ROUTING_UTIL_WITH_FORMULA) {
890887
g->draw_text(bb.center(),
891-
vtr::string_fmt("%.2f = %.0f / %.0f", chany_util,
892-
chany_usage[x][y], chany_avail[x][y])
893-
.c_str(),
888+
vtr::string_fmt("%.2f = %.0f / %.0f", chany_util, chany_usage[x][y], chany_avail[x][y]),
894889
bb.width(), bb.height());
895890
}
896891

@@ -938,7 +933,7 @@ void draw_routing_util(ezgl::renderer* g) {
938933
|| draw_state->show_routing_util
939934
== DRAW_ROUTING_UTIL_WITH_FORMULA) {
940935
g->draw_text(bb.center(),
941-
vtr::string_fmt("%.2f", sb_util).c_str(), bb.width(),
936+
vtr::string_fmt("%.2f", sb_util), bb.width(),
942937
bb.height());
943938
}
944939
}
@@ -1176,7 +1171,7 @@ void draw_flyline_timing_edge(ezgl::point2d start, ezgl::point2d end, float incr
11761171
- 8 * cos(text_angle * (std::numbers::pi / 180));
11771172

11781173
ezgl::point2d offset_text_bbox(x_offset, y_offset);
1179-
g->draw_text(offset_text_bbox, incr_delay_str.c_str(),
1174+
g->draw_text(offset_text_bbox, incr_delay_str,
11801175
text_bbox.width(), text_bbox.height());
11811176

11821177
g->set_font_size(14);
@@ -1299,19 +1294,17 @@ void draw_color_map_legend(const vtr::ColorMap& cmap,
12991294
//Min mark
13001295
g->set_color(blk_SKYBLUE); // set to skyblue so its easier to see
13011296
std::string str = vtr::string_fmt("%.3g", cmap.min());
1302-
g->draw_text({legend.center_x(), legend.top() - TEXT_OFFSET},
1303-
str.c_str());
1297+
g->draw_text({legend.center_x(), legend.top() - TEXT_OFFSET}, str);
13041298

13051299
//Mid marker
13061300
g->set_color(ezgl::BLACK);
13071301
str = vtr::string_fmt("%.3g", cmap.min() + (cmap.range() / 2.));
1308-
g->draw_text({legend.center_x(), legend.center_y()}, str.c_str());
1302+
g->draw_text({legend.center_x(), legend.center_y()}, str);
13091303

13101304
//Max marker
13111305
g->set_color(ezgl::BLACK);
13121306
str = vtr::string_fmt("%.3g", cmap.max());
1313-
g->draw_text({legend.center_x(), legend.bottom() + TEXT_OFFSET},
1314-
str.c_str());
1307+
g->draw_text({legend.center_x(), legend.bottom() + TEXT_OFFSET}, str);
13151308

13161309
g->set_color(ezgl::BLACK);
13171310
g->draw_rectangle(legend);

0 commit comments

Comments
 (0)