Skip to content

[clang-tidy] Check request: performance-construct-regex-only-once #121276

@denzor200

Description

@denzor200

Construction time of a std::regex variable might be a bottleneck.
Thus we should never declare it as non-static block-scope variable in order to variable gets initialised only once.

std::regex r1("(.*)");            // OK
static std::regex r2("(.*)");     // OK
void process() {
    std::regex r3("(.*)");        // INCORRECT
    static std::regex r4("(.*)"); // OK
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions