esp-cpp / espp

C++ components for ESP
https://esp-cpp.github.io/espp/
MIT License
28 stars 9 forks source link

feat: Update `Logger` and `BaseComponent` to return tag/name as const ref #245

Closed finger563 closed 1 month ago

finger563 commented 1 month ago

Description

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

Checklist:

Software

github-actions[bot] commented 1 month ago

:white_check_mark:Static analysis result - no issues found! :white_check_mark: