Closed bocchino closed 2 months ago
I've noticed during past projects that the format specifier strings can take up a lot of code, and the assignment operator is a natural way to code. Could we move the operator to the derived class?
In most cases the proposed change will reduce code. For example instead of doing
we'll just do
In a few cases we'll have to add a format string "%s"
, but this is a negligible difference, and I think it only happens in unit tests. We could keep sb = "foo"
in those cases, but then I think we'll need to have a public assignment operator in the base class, since the base class appears on the left-hand side of the assignment.
Covered by #423. We can keep the assignment into StringBase for now, but we should remove the extra buffer copy where possible.
Instead of
sb = "foo"
we should dosb.format("%s", "foo")
. In some cases this will remove an extra buffer and ansnprintf
. Then we can make the copy assignment operator protected in the StringBase class.