Skip to content

static const char* const may be replaced with static const char[] #847

Open
@xezon

Description

@xezon

static const char* const may be replaced with static const char[]. It allows to use sizeof(arr) or better ARRAY_SIZE(arr) to compute the length instead of using strlen(arr) at runtime. Alternatively it could be static const std::string_view with modern CPP.

For function locals, const char[] is not automatically the better choice, because that will copy the data string into the stack.

static const char* (as opposed to static const char* const) may need to stay if it is reassigned to different strings at runtime (the compiler will tell).

Raised by Caball009

Metadata

Metadata

Assignees

No one assigned

    Labels

    InvestigateMinorSeverity: Minor < Major < Critical < BlockerPerformanceIs a performance concernRefactorEdits the code with insignificant behavior changes, is never user facing

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions