Problem
Every LogScope object allocates a heap string for its name:
// Current — heap allocation per scope
class LogScope
{
const String mScopeName; // std::string inside — heap alloc
const bool mIsRegistered; // redundant: constructor always registers
...
};
There are 500+ LogScope objects in areg-sdk (one per method in larger modules). Each
constructs and destructs an areg::String, triggering a new/delete pair at static
initialization and (effectively) at shutdown. This is pure overhead — the scope name is
always a string literal with static storage duration.
Goal
- Zero heap allocation for
mScopeName
- Compile-time enforcement of the maximum scope name length (
LENGTH_SCOPE = 256)
- Remove the now-unused
mIsRegistered flag
- Remove the
LogScope(const InStream&) constructor (only one call site, which can be replaced)
Problem
Every
LogScopeobject allocates a heap string for its name:There are 500+
LogScopeobjects in areg-sdk (one per method in larger modules). Eachconstructs and destructs an
areg::String, triggering anew/deletepair at staticinitialization and (effectively) at shutdown. This is pure overhead — the scope name is
always a string literal with static storage duration.
Goal
mScopeNameLENGTH_SCOPE = 256)mIsRegisteredflagLogScope(const InStream&)constructor (only one call site, which can be replaced)