clear up plugin string usage ambiguities reported by gcc#10942
clear up plugin string usage ambiguities reported by gcc#10942traeak merged 1 commit intoapache:masterfrom
Conversation
| @@ -117,12 +117,15 @@ template <class T> class RateLimiter | |||
| memset(_metrics, 0, sizeof(_metrics)); | |||
|
|
|||
| std::string metric_prefix = prefix; | |||
There was a problem hiding this comment.
Should you use the std::string::reserve() member function for these so there will be only one heap allocation?
There was a problem hiding this comment.
Should you use the std::string::reserve() member function for these so there will be only one heap allocation?
This function is "initializeMetrics" which is only called during plugin initialization. And there's more logic below in the function for building this metric_prefix string. You might save one heap allocation with a reserve for something not in a performance sensitive place with probably too high a maintenance cost.
There was a problem hiding this comment.
OK it looked like a performance PR to me. What are the ambiguities in the current code?
There was a problem hiding this comment.
I suspect it's due to the std::string/std::string_view handling (circular dependency hell) where the compiler might get confused trying to figure out how to deal with the first argument in the following (for example):
result += "/" + somestringfunc();
This clears up some warnings with CI gcc-12 release branch builds.
tested with ubuntu:23.04 CI image with gcc/release combination.