Open LouisAsanaka opened 5 years ago
Where can you see that it instantiates a new object every time?
In the CANSparkMax class, line 213.
Okay, sure. In this case constructing an instance of CANEncoder
does not seem too expensive since the class seems to only contain a pointer to the CANSparkMax
object. But if you want to open a PR for this then that's fine.
This is not an urgent issue, but there might be some inefficiencies when getting the encoder positions on from the SparkMaxes. The
CANSparkMax
class has a methodgetEncoder()
, which for some reason instantiates a newCANEncoder
object every time it is called. Using theSparkMaxPrime
class inraidzero.robot.components
changes this, as only one encoder object is created throughout the object's lifetime.