Skip to content

Avoid dynamic_casts in the inner loop of GeometryPath calculations #1603

Open
@aseth1

Description

@aseth1

In #1595 it became apparent that dynamic_casts of PathPoint to test if they were MovingPathPoints, or not, could be avoided if the the abstract interface were more complete. For example, implementing the pure virtual getLocation(state) avoids having to dynamic_cast to call getLocation() on Stations. Furthermore, if the virtual function that returns the partial velocity of a point with respect to is parent frame is zero, then it is clearly not moving. Similar virtual functions could be used (added) to avoid dynamic_casts completely.
The main advantages are:

  1. makes the code straightforward and easier to read/maintain
  2. better performance (virtual function call has a fixed/constant access time, where as dynamic_casts are implementation dependent) but needs to be profiled

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions