You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
C++: Clinched values are constructed, then copied and moved:
Copied when passed to the add function by value
Moved when we push_back onto the value containers
Instead, pass the add functions the args by which to construct, and emplace_back.
Or not. We'd still construct the string via the + operator, and move it to the container.
Why not just pass the strings to add_cfoo as an rvalue reference.
Consider using pointers, to cut down on copy operations when resizing the vector.
Or not. It's move instructions that are involved here, which are already very low cost (as I see from my attempts to store args rather than strings). Pointers would just be more trouble than they're worth.
Longer term, look into storing the args themselves, not full strings, and saving RAM.
How much RAM does this whole structure take up anyway?
Could a similar arrangement also benefit Python slightly? Would need to rewrite as a class; it's just 3 lists currently. A pretty simple task though.
push_backonto the value containersInstead, pass the add functions the args by which to construct, andemplace_back.Or not. We'd still construct the string via the + operator, and move it to the container.
add_cfooas an rvalue reference.Consider using pointers, to cut down on copy operations when resizing the vector.Or not. It's move instructions that are involved here, which are already very low cost (as I see from my attempts to store args rather than strings). Pointers would just be more trouble than they're worth.