martinzink commented on a change in pull request #1259:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1259#discussion_r805754831
##########
File path: libminifi/include/core/Core.h
##########
@@ -80,13 +81,16 @@ static inline std::string getClassName() {
std::free(b);
return name;
#else
- std::string adjusted_name = typeid(T).name();
- // can probably skip class manually for slightly higher performance
- const std::string clazz = "class ";
- auto haz_clazz = adjusted_name.find(clazz);
- if (haz_clazz == 0)
- adjusted_name = adjusted_name.substr(clazz.length(),
adjusted_name.length() - clazz.length());
- return adjusted_name;
+ std::string_view name = typeid(T).name();
+ const std::string_view class_prefix = "class ";
+ const std::string_view struct_prefix = "struct ";
+
+ if (name.find(class_prefix) == 0) {
Review comment:
Since C++20 we can use
[starts_with](https://en.cppreference.com/w/cpp/string/basic_string_view/starts_with)
which is a bit more readable (same applies to line 90)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]