Skip to content

Conversation

codeinred
Copy link
Contributor

I'm currently working on a memory profiler, and I noticed that 880 bytes was always being allocated at the start of any program that I tested. This allocation was due to punctuators_and_operators, inside cpptrace.

image

I've created this MR to convert punctuators_and_operators into a statically allocated array, so that cpptrace doesn't do any allocations on initialization.

@ZXShady
Copy link

ZXShady commented Aug 23, 2025

decalre the array as static and constexpr otherwise it will be reconstructed everytime on the stack

@codeinred
Copy link
Contributor Author

@ZXShady this array is a global constant. It’s namespace-scope. Some older compilers don’t support constexpr std::string_view, and that’s why i didn’t use constexpr here. if you look at the surrounding arrays, none of those are declared constexpr either

@ZXShady
Copy link

ZXShady commented Aug 25, 2025

my bad, thought it was function local

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants