Closed snozawa closed 4 months ago
@snozawa I understand the need. But in the interest of keeping the API clean and not having to worry about calling Reserve after Init is called, how about adding a second parameter to TrajectoryBase::Init
instead, which will only allow the user to reserve the points on initialization of the trajectory?
@snozawa I understand the need. But in the interest of keeping the API clean and not having to worry about calling Reserve after Init is called, how about adding a second parameter to
TrajectoryBase::Init
instead, which will only allow the user to reserve the points on initialization of the trajectory?
thanks for your comment!
That makes sense!
I updated Init
function to support reserving of memory, and by default, reserving is disabled.
Thanks!
Summary
Reserve
API toTrajectoryBase
and implement it forGenericTrajectory
.Description
Insert
might be called from the time-critical code path. To mitigate the risk of dynamic memory allocation inside ofInsert
, implementReserve
API.Reserve
API hasoptions
flag, so that the user can decide whether to save_vtrajdata
only or to save_vtrajdata
and other data altogether. Other data like_vaccumtime
might not be used as long as the user does not useSample
-related APIs. In such case, the user might want to skip unnecessary memory pre-allocation.