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.
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
, wherefilter_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 functionfilter_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.