Skip to content

Commit 7a99778

Browse files
committed
gui: speed up the select command
- Only contruct the regex once - Identify "simple" patterns that don't need a regex match and simple string comparison is enough - Replace Descriptor::getAllObjects with visitAllObjects to save allocation/deallocation cost. Future work could include a direct find of a simple name rather than a full iteration of all objects. Signed-off-by: Matt Liberty <[email protected]>
1 parent a4390e1 commit 7a99778

File tree

14 files changed

+350
-313
lines changed

14 files changed

+350
-313
lines changed

src/drt/src/dr/FlexDR_graphics.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class GridGraphDescriptor : public gui::Descriptor
3838
gui::Selected makeSelected(std::any object) const override;
3939
bool lessThan(std::any l, std::any r) const override;
4040

41-
bool getAllObjects(gui::SelectionSet& objects) const override;
41+
void visitAllObjects(
42+
const std::function<void(const gui::Selected&)>& func) const override;
4243
};
4344

4445
std::string GridGraphDescriptor::getName(std::any object) const
@@ -187,9 +188,9 @@ bool GridGraphDescriptor::lessThan(std::any l, std::any r) const
187188
< std::tie(r_grid.x, r_grid.y, r_grid.z);
188189
}
189190

190-
bool GridGraphDescriptor::getAllObjects(gui::SelectionSet& objects) const
191+
void GridGraphDescriptor::visitAllObjects(
192+
const std::function<void(const gui::Selected&)>& func) const
191193
{
192-
return false;
193194
}
194195

195196
//////////////////////////////////////////////////

src/gui/include/gui/gui.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,9 @@ class Descriptor
312312
virtual bool isInst(std::any /* object */) const { return false; }
313313
virtual bool isNet(std::any /* object */) const { return false; }
314314

315-
virtual bool getAllObjects(SelectionSet& /* objects */) const = 0;
315+
virtual void visitAllObjects(
316+
const std::function<void(const Selected&)>& func) const
317+
= 0;
316318

317319
// A property is a name and a value.
318320
struct Property

src/gui/src/bufferTreeDescriptor.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,24 +199,23 @@ bool BufferTreeDescriptor::lessThan(std::any l, std::any r) const
199199
return l_bnet->getName() < r_bnet->getName();
200200
}
201201

202-
bool BufferTreeDescriptor::getAllObjects(SelectionSet& objects) const
202+
void BufferTreeDescriptor::visitAllObjects(
203+
const std::function<void(const Selected&)>& func) const
203204
{
204205
auto* chip = db_->getChip();
205206
if (chip == nullptr) {
206-
return false;
207+
return;
207208
}
208209
auto* block = chip->getBlock();
209210
if (block == nullptr) {
210-
return false;
211+
return;
211212
}
212213

213214
for (auto* net : block->getNets()) {
214215
if (BufferTree::isAggregate(net)) {
215-
objects.insert(makeSelected(BufferTree(net)));
216+
func({BufferTree(net), this});
216217
}
217218
}
218-
219-
return true;
220219
}
221220

222221
Descriptor::Actions BufferTreeDescriptor::getActions(std::any object) const

src/gui/src/bufferTreeDescriptor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class BufferTreeDescriptor : public Descriptor
6868
Selected makeSelected(std::any object) const override;
6969
bool lessThan(std::any l, std::any r) const override;
7070

71-
bool getAllObjects(SelectionSet& objects) const override;
71+
void visitAllObjects(
72+
const std::function<void(const Selected&)>& func) const override;
7273

7374
private:
7475
odb::dbDatabase* db_;

0 commit comments

Comments
 (0)