Update espp::Logger::get_tag() to return a const reference to the name.
Update espp::BaseComponent::get_name() to return a const reference to the name.
Motivation and Context
It's a minor optimization which also helps those values be passed around to c functions which expect a c-style string. Returning a const reference allows object.get_name().c_str() to remain valid and therefore useful, such as in the espp::HighResolutionTimer which uses the get_name().c_str() as the name for the timer itself. Previously, this would result in a garbage name in the esp_timer dump info because that temporary string was lost.
How has this been tested?
Building and running the timer example.
Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):
Types of changes
[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
[ ] Documentation Update
[ ] Hardware (schematic, board, system design) change
[x] Software change
Checklist:
[ ] My change requires a change to the documentation.
[ ] I have added / updated the documentation related to this change via either README or WIKI
Software
[ ] I have added tests to cover my changes.
[ ] I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
[x] All new and existing tests passed.
[x] My code follows the code style of this project.
Description
espp::Logger::get_tag()
to return a const reference to the name.espp::BaseComponent::get_name()
to return a const reference to the name.Motivation and Context
It's a minor optimization which also helps those values be passed around to c functions which expect a c-style string. Returning a const reference allows
object.get_name().c_str()
to remain valid and therefore useful, such as in theespp::HighResolutionTimer
which uses theget_name().c_str()
as the name for the timer itself. Previously, this would result in a garbage name in the esp_timer dump info because that temporary string was lost.How has this been tested?
Building and running the timer example.
Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):
Types of changes
Checklist:
Software
.github/workflows/build.yml
file to add my new test to the automated cloud build github action.