Merged
Conversation
```cpp
TimePoint TimeCache::getLatestTimestamp()
{
return storage_.front().stamp_;
}
```
And std::list<T>::front() is(gcclib):
```cpp
reference
front() _GLIBCXX_NOEXCEPT
{ return *begin(); }
```
```cpp
TimePoint TimeCache::getLatestTimestamp()
{
// empty list case
// ...
return storage_.front().stamp_;
}
```
and std::list<T>::front():
```cpp
reference
front() _GLIBCXX_NOEXCEPT
{ return *begin(); }
```
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
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 if any element is older thant the max_storage_time_ allowed, relative to the latest(sooner) time seems clear npw
Contributor
|
@ahcorde is this ready to merge? can you confirm? |
This was referenced May 9, 2024
ahcorde
pushed a commit
that referenced
this pull request
May 29, 2024
* 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
ahcorde
pushed a commit
that referenced
this pull request
May 29, 2024
* 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
ahcorde
added a commit
that referenced
this pull request
May 29, 2024
…kport #680) (#694) * Nacho/minor fixes tf2 cache (#658) * 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 * [TimeCache] Improve performance for insertData() and pruneList() (#680) Signed-off-by: Eric Cousineau <eric.cousineau@tri.global> Co-authored-by: Chris Lalancette <clalancette@gmail.com> * Don't break ABI Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com> --------- Signed-off-by: Eric Cousineau <eric.cousineau@tri.global> Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com> Co-authored-by: Ignacio Vizzo <ignacio@dexory.com> Co-authored-by: Eric Cousineau <eric.cousineau@tri.global> Co-authored-by: Chris Lalancette <clalancette@gmail.com> Co-authored-by: Alejandro Hernández Cordero <ahcorde@gmail.com>
ahcorde
added a commit
that referenced
this pull request
May 29, 2024
…kport #680) (#693) * Nacho/minor fixes tf2 cache (#658) * 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 * [TimeCache] Improve performance for insertData() and pruneList() (#680) Signed-off-by: Eric Cousineau <eric.cousineau@tri.global> Co-authored-by: Chris Lalancette <clalancette@gmail.com> * Don't break ABI Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com> --------- Signed-off-by: Eric Cousineau <eric.cousineau@tri.global> Signed-off-by: Alejandro Hernández Cordero <ahcorde@gmail.com> Co-authored-by: Ignacio Vizzo <ignacio@dexory.com> Co-authored-by: Eric Cousineau <eric.cousineau@tri.global> Co-authored-by: Chris Lalancette <clalancette@gmail.com> Co-authored-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.
Follow up on #636
This PR does not introduce any real change, it's just a selective refactor on some parts of the tf2 cache I did back then. It's mainly replacing raw loops with algorithms that one can read and understand what's the code trying to do faster
This also means I didn't embark on a refactoring journey of the entire system. It's just affecting the line of code I was evaluating last year, but I didn't want to avoid contributing to this.
Of course, it would be ideal to refactor more "globally" let's call it but won't have time anytime soon to do this, I'm happy to follow up more reviewing of the implementation in future PRs but for now this is what I can do :)
I tried to be very verbose on a committed level just to make the reviewing process easier