Skip to content

[phase 3] LogScope Optimization - Zero Heap Allocation for Scope Name #698

@aregtech

Description

@aregtech

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)

Metadata

Metadata

Assignees

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions