parallaxsw / OpenSTA

GNU General Public License v3.0
52 stars 23 forks source link

Refactor using C++ templates? #59

Closed akashlevy closed 3 months ago

akashlevy commented 4 months ago

Throughout the OpenSTA codebase, I notice there are a few instances of duplicated code, where a function's body is equivalent except for one or more of the argument/return types. This seems like an opportunity to use C++ templates here to follow DRY principle and thereby improve code maintainability. I am noticing that it would make some of my future PRs significantly less verbose and easier to validate.

An example is in tcl/StaTcl.i, where filter_insts, filter_pins, filter_ports, filter_timing_arcs are essentially equivalent, just with different types. Using C++ templates, you could reduce this to a single function filter_objects with templates for the arg/return types.

Let me know if refactoring to templates is of interest--I'm happy to try to spin some PRs if so. No worries if not as well.

jjcherry56 commented 4 months ago

Hold off on PRs on StaTcl.i because I have a pending reorg that splits it into multiple files.

akashlevy commented 4 months ago

Cool