Skip to content

Commit eb0d5a6

Browse files
committed
fix readability-container-contains
Signed-off-by: Matt Liberty <[email protected]>
1 parent e5f471b commit eb0d5a6

21 files changed

+42
-42
lines changed

src/cts/src/TritonCTS.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void TritonCTS::checkCharacterization()
249249
techChar_->forEachWireSegment([&](unsigned idx, const WireSegment& wireSeg) {
250250
for (int buf = 0; buf < wireSeg.getNumBuffers(); ++buf) {
251251
const std::string& master = wireSeg.getBufferMaster(buf);
252-
if (visitedMasters.count(master) == 0) {
252+
if (!visitedMasters.contains(master)) {
253253
if (masterExists(master)) {
254254
visitedMasters.insert(master);
255255
} else {

src/dpl/src/Place.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ PixelPt Opendp::searchNearestSite(const Node* cell,
792792
for (GridPt offset : neighbors) {
793793
GridPt neighbor = {nearest.x + offset.x, nearest.y + offset.y};
794794
// Check if it was already put in the queue
795-
if (visited.count(neighbor) > 0) {
795+
if (visited.contains(neighbor)) {
796796
continue;
797797
}
798798
// Check limits

src/gui/src/bufferTreeDescriptor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ Descriptor::Actions BufferTreeDescriptor::getActions(
235235
Descriptor::Actions actions;
236236
bool is_focus = true;
237237
for (auto* net : bnet.getNets()) {
238-
is_focus &= focus_nets_.count(net) != 0;
238+
is_focus &= focus_nets_.contains(net);
239239
}
240240
if (!is_focus) {
241241
actions.push_back(Descriptor::Action{"Focus", [this, gui, &bnet]() {
@@ -261,7 +261,7 @@ Descriptor::Actions BufferTreeDescriptor::getActions(
261261
bool guides_on = false;
262262
for (auto* net : bnet.getNets()) {
263263
guides_on
264-
|= guide_nets_.count(net) != 0;
264+
|= guide_nets_.contains(net);
265265
}
266266
for (auto* net : bnet.getNets()) {
267267
if (!guides_on) {
@@ -282,7 +282,7 @@ Descriptor::Actions BufferTreeDescriptor::getActions(
282282
Descriptor::Action{"Tracks", [this, gui, &bnet]() {
283283
bool tracks_on = false;
284284
for (auto* net : bnet.getNets()) {
285-
tracks_on |= tracks_nets_.count(net) != 0;
285+
tracks_on |= tracks_nets_.contains(net);
286286
}
287287
for (auto* net : bnet.getNets()) {
288288
if (!tracks_on) {

src/gui/src/dbDescriptors.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,7 @@ Descriptor::Actions DbNetDescriptor::getActions(const std::any& object) const
19231923

19241924
auto* gui = Gui::get();
19251925
Descriptor::Actions actions;
1926-
if (focus_nets_.count(net) == 0) {
1926+
if (!focus_nets_.contains(net)) {
19271927
actions.push_back(Descriptor::Action{"Focus", [this, gui, net]() {
19281928
gui->addFocusNet(net);
19291929
return makeSelected(net);
@@ -1963,7 +1963,7 @@ Descriptor::Actions DbNetDescriptor::getActions(const std::any& object) const
19631963
}});
19641964
}
19651965
if (!net->getGuides().empty()) {
1966-
if (guide_nets_.count(net) == 0) {
1966+
if (!guide_nets_.contains(net)) {
19671967
actions.push_back(
19681968
Descriptor::Action{"Show Route Guides", [this, gui, net]() {
19691969
gui->addRouteGuides(net);
@@ -1978,7 +1978,7 @@ Descriptor::Actions DbNetDescriptor::getActions(const std::any& object) const
19781978
}
19791979
}
19801980
if (!net->getTracks().empty()) {
1981-
if (tracks_nets_.count(net) == 0) {
1981+
if (!tracks_nets_.contains(net)) {
19821982
actions.push_back(Descriptor::Action{"Show Tracks", [this, gui, net]() {
19831983
gui->addNetTracks(net);
19841984
return makeSelected(net);

src/gui/src/displayControls.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,7 @@ QFont DisplayControls::ioPinMarkersFont() const
19221922

19231923
void DisplayControls::registerRenderer(Renderer* renderer)
19241924
{
1925-
if (custom_controls_.count(renderer) != 0) {
1925+
if (custom_controls_.contains(renderer)) {
19261926
// already registered
19271927
return;
19281928
}
@@ -2023,7 +2023,7 @@ void DisplayControls::unregisterRenderer(Renderer* renderer)
20232023
{
20242024
saveRendererState(renderer);
20252025

2026-
if (custom_controls_.count(renderer) == 0) {
2026+
if (!custom_controls_.contains(renderer)) {
20272027
return;
20282028
}
20292029

@@ -2304,7 +2304,7 @@ void DisplayControls::setOnlyVisibleLayers(
23042304
}
23052305

23062306
for (auto* layer : layers) {
2307-
if (layer_controls_.count(layer) != 0) {
2307+
if (layer_controls_.contains(layer)) {
23082308
layer_controls_[layer].visible->setCheckState(Qt::Checked);
23092309
}
23102310
}

src/gui/src/gui.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void Gui::registerRenderer(Renderer* renderer)
242242

243243
void Gui::unregisterRenderer(Renderer* renderer)
244244
{
245-
if (renderers_.count(renderer) == 0) {
245+
if (!renderers_.contains(renderer)) {
246246
return;
247247
}
248248

@@ -944,7 +944,7 @@ void Gui::registerHeatMap(HeatMapDataSource* heatmap)
944944

945945
void Gui::unregisterHeatMap(HeatMapDataSource* heatmap)
946946
{
947-
if (heat_maps_.count(heatmap) == 0) {
947+
if (!heat_maps_.contains(heatmap)) {
948948
return;
949949
}
950950

@@ -994,7 +994,7 @@ void Gui::setHeatMapSetting(const std::string& name,
994994
} else {
995995
auto settings = source->getSettings();
996996

997-
if (settings.count(option) == 0) {
997+
if (!settings.contains(option)) {
998998
QStringList options;
999999
options.append(QString::fromStdString(rebuild_map_option));
10001000
for (const auto& [key, kv] : settings) {
@@ -1065,7 +1065,7 @@ Renderer::Setting Gui::getHeatMapSetting(const std::string& name,
10651065

10661066
auto settings = source->getSettings();
10671067

1068-
if (settings.count(option) == 0) {
1068+
if (!settings.contains(option)) {
10691069
QStringList options;
10701070
for (const auto& [key, kv] : settings) {
10711071
options.append(QString::fromStdString(key));

src/gui/src/layoutViewer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ Selected LayoutViewer::selectAtPoint(const odb::Point& pt_dbu)
10801080
std::vector<bool> is_selected;
10811081
is_selected.reserve(selections.size());
10821082
for (auto& sel : selections) {
1083-
is_selected.push_back(selected_.count(sel) != 0);
1083+
is_selected.push_back(selected_.contains(sel));
10841084
}
10851085
if (std::all_of(
10861086
is_selected.begin(), is_selected.end(), [](bool b) { return b; })) {

src/gui/src/mainWindow.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -924,9 +924,9 @@ std::string MainWindow::addToolbarButton(const std::string& name,
924924
// default to "buttonX" naming
925925
key = "button" + std::to_string(key_idx);
926926
key_idx++;
927-
} while (buttons_.count(key) != 0);
927+
} while (buttons_.contains(key));
928928
} else {
929-
if (buttons_.count(name) != 0) {
929+
if (buttons_.contains(name)) {
930930
logger_->error(utl::GUI, 22, "Button {} already defined.", name);
931931
}
932932
key = name;
@@ -951,7 +951,7 @@ std::string MainWindow::addToolbarButton(const std::string& name,
951951

952952
void MainWindow::removeToolbarButton(const std::string& name)
953953
{
954-
if (buttons_.count(name) == 0) {
954+
if (!buttons_.contains(name)b) {
955955
return;
956956
}
957957

@@ -1020,9 +1020,9 @@ std::string MainWindow::addMenuItem(const std::string& name,
10201020
// default to "actionX" naming
10211021
key = "action" + std::to_string(key_idx);
10221022
key_idx++;
1023-
} while (menu_actions_.count(key) != 0);
1023+
} while (menu_actions_.contains(key));
10241024
} else {
1025-
if (menu_actions_.count(name) != 0) {
1025+
if (menu_actions_.contains(name)) {
10261026
logger_->error(utl::GUI, 25, "Menu action {} already defined.", name);
10271027
}
10281028
key = name;
@@ -1081,7 +1081,7 @@ void MainWindow::removeMenu(QMenu* menu)
10811081

10821082
void MainWindow::removeMenuItem(const std::string& name)
10831083
{
1084-
if (menu_actions_.count(name) == 0) {
1084+
if (!menu_actions_.contains(name)) {
10851085
return;
10861086
}
10871087

src/gui/src/staGui.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ void TimingConeRenderer::drawObjects(gui::Painter& painter)
792792
odb::dbInst* inst = pin->getPinAsITerm()->getInst();
793793

794794
if (inst != nullptr) {
795-
if (instances.count(inst) == 0) {
795+
if (!instances.contains(inst)) {
796796
instances[inst] = pin.get();
797797
} else {
798798
auto& worst_pin = instances[inst];
@@ -1377,4 +1377,4 @@ const sta::ClockSet* TimingControlsDialog::getClocks()
13771377
return &selected_clocks_;
13781378
}
13791379

1380-
} // namespace gui
1380+
} // namespace gui

src/gui/src/staGuiInterface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ ConeDepthMap STAGuiInterface::buildConeConnectivity(
13481348

13491349
for (const auto& [level, pin_list] : map) {
13501350
int next_level = level + 1;
1351-
if (map.count(next_level) == 0) {
1351+
if (!map.contains(next_level)) {
13521352
break;
13531353
}
13541354

0 commit comments

Comments
 (0)