Constructing a namespace scoped std::string will involve a heap allocation for strings longer than 8 characters (with MSVC, about 10 characters last I checked for libc++ and libstdc++). Move the sdkVersion string to a method scoped magic static so it's only constructed on the first call to that method.
@@ -473,10 +473,9 @@ namespace PAL_NS_BEGIN {
#define OS_NAME "Unknown"
#endif
- static const std::string sdkVersion(EVTSDK_VERSION_PREFIX "-" OS_NAME "-C++-" ECS_SUPP "-" BUILD_VERSION_STR);
-
const std::string& getSdkVersion()
{
+ static const std::string sdkVersion(EVTSDK_VERSION_PREFIX "-" OS_NAME "-C++-" ECS_SUPP "-" BUILD_VERSION_STR);
return sdkVersion;
}
