-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Port curve container types to std::vector
#1635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
416c44b to
711272f
Compare
711272f to
68cd698
Compare
|
how about std::deque? especially since we probably can't retain all events for the whole game and need to either serialize/forget them at earlier times |
|
@TheJJ |
|
we can test/benchmark when it gets relevant, and we can easily swap it hopefully ^^ |
|
As long as we get rid of the list, it should be an improvement either way :D |
|
then why not try the deque? :) should definitely be an improvement for the regular use-cases |
|
I've created a new branch in #1637 to preserve the changes from this PR. We could still switch to vector in the future :) |
|
After a quick detour with #1637 I think using vector is the better choice :D Iterator stability for I also found a C++ benchmark – std::vector VS std::list VS std::deque which compares the standard containers performance. Looks like vector is still not that much slower than deque, even for random inserts. |
68cd698 to
a0ef6e1
Compare
| } | ||
|
|
||
| private: | ||
| time::time_t timestamp = time::TIME_MIN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not leave the time as a const member? then no function to access it is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is const then it is not copy assignable/constructible which becomes a problem for working with vector (or deque). I know I can write a new copy/assignment contructor but making them private looks more clean to me.
74fe1f3 to
76e18a7
Compare
76e18a7 to
1ad330e
Compare
1ad330e to
d2349d5
Compare
|
It's ready to review again! |
So far, we have used
std::listas the underlying type for curve containers. Lists are nice because they offer constant time insertions and erasure from anywhere in the data structure and have stable iterators, i.e. changing the list doesn't invaliate the iterators.However, these properties may not be as important for our applications and
std::vectorcould be better for performance under these assumptions:std::vectorat an advantage overstd::listThis PR changes the underlying container type of
KeyframeContainerandQueuetostd::vectorto show that its usage is possible with minimal changes.