From 86699b42f619960bfefd4d0b479dd44a90527ea4 Mon Sep 17 00:00:00 2001 From: gatecat Date: Sat, 26 Feb 2022 15:17:46 +0000 Subject: Switch to potentially-sparse net users array This uses a new data structure for net.users that allows gaps, so removing a port from a net is no longer an O(n) operation on the number of users the net has. Signed-off-by: gatecat --- common/design_utils.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'common/design_utils.h') diff --git a/common/design_utils.h b/common/design_utils.h index 63cb71d7..069600b5 100644 --- a/common/design_utils.h +++ b/common/design_utils.h @@ -47,14 +47,18 @@ CellInfo *net_only_drives(const Context *ctx, NetInfo *net, F1 cell_pred, IdStri return nullptr; if (exclusive) { if (exclude == nullptr) { - if (net->users.size() != 1) + if (net->users.entries() != 1) return nullptr; } else { - if (net->users.size() > 2) { + if (net->users.entries() > 2) { return nullptr; - } else if (net->users.size() == 2) { - if (std::find_if(net->users.begin(), net->users.end(), - [exclude](const PortRef &ref) { return ref.cell == exclude; }) == net->users.end()) + } else if (net->users.entries() == 2) { + bool found = false; + for (auto &usr : net->users) { + if (usr.cell == exclude) + found = true; + } + if (!found) return nullptr; } } -- cgit v1.2.3