[TimeCache] Improve performance for insertData() and pruneList() (backport #680)#694
Merged
[TimeCache] Improve performance for insertData() and pruneList() (backport #680)#694
Conversation
Contributor
Author
|
Cherry-pick of d700d78 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
* Remove unused parameter
* Make use of API function to improve redability
```cpp
TimePoint TimeCache::getLatestTimestamp()
{
return storage_.front().stamp_;
}
```
And std::list<T>::front() is(gcclib):
```cpp
reference
front() _GLIBCXX_NOEXCEPT
{ return *begin(); }
```
* Same argument as 321bd22
```cpp
TimePoint TimeCache::getLatestTimestamp()
{
// empty list case
// ...
return storage_.front().stamp_;
}
```
and std::list<T>::front():
```cpp
reference
front() _GLIBCXX_NOEXCEPT
{ return *begin(); }
```
* Improve readbility by relying on STL functions
By now reading to this block I can tell that we are preventing to
inserting a new element in the list, that has a timestamp that is
actually older than the max_storage_time_ we allow for
* Remove hardcoded algorithmg for STL one
The intent of the code is now more clear, instead of relying on raw
loops, we "find if" there is any element in the list that has a stamp
older than the incoming one. With this we find the position in the list
where we should insert the current timestamp: `storage_it`
* Remove to better express what this pointer is represetngin
* Replace raw loop for STL algorithm
Remove if any element is older thant the max_storage_time_ allowed,
relative to the latest(sooner) time seems clear npw
Signed-off-by: Eric Cousineau <eric.cousineau@tri.global> Co-authored-by: Chris Lalancette <clalancette@gmail.com>
4f1e4c1 to
d1143f5
Compare
Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #676
Per #676 (comment), this should yield a ~1000x speedup for
insertData(for inserting new data only)This is an automatic backport of pull request #680 done by Mergify.