Use perfect forwarding for StringObject::create#2772
Conversation
6ad888e to
7f5e85f
Compare
seven1m
left a comment
There was a problem hiding this comment.
Well ain't that fancy!
Does the template programming slow down compilation at all? I do worry that using template programming seems to be slower (at compile time), at least with gcc.
5797d6c to
35e09dd
Compare
35e09dd to
3a8f4a3
Compare
This removes the need for all the duplication of the constructors.
3a8f4a3 to
06f1dec
Compare
This is an interesting question when running at -O3. Legend has it that -O2 is a better balance of compilation time vs perf. But no inlining? Dunno what clang and gcc actually do nowadays. I'm actually surprised that member fields can be forward-referenced in header files. My C++ foo is a bit rusty. In any case we could definitely factor some of the instruction->c++ generation in order to cut parsing at least. |
This removes all the specialized implementations of
StringObject::createwith a generic one that just forwards the arguments to the actual private constructors. We can do the same thing with all other classes that have these create factory methods.Small caveat: perfect forwarding is not perfect. The callers that use a stack allocated array don't work, these have been converted into calls using
TM::String::create_and_take_ownershipwhich removes a memcpy too.