Andre Poenitz wrote:
That's only part of the problem. The sharing involves atomic operations
for bumping the reference counter which is about the best rat poison one
can get for performance on multicore systems - but that doesn't hit us
here as desktops most like don't have much more then two CPU cores
nowadays.
The main problem is the dynamic allocation of the QString data
(and possible reallocations at append() time. Having that once
per displayed char is pretty expensive.
Which is why I suggested to get rid of the function call.
Not only the call itself (which inlining fixes nicely) but
the possibly excessive work done.
If the conversion is done without calls, chances are
it can be done with no allocations "per character".
Perhaps one allocation per string.
A problem when relying on too many method calls, is that
one end up doing allocations and such in methods that
are called often. Stuff more work into a single function, and you
see how to avoid allocations (and other expensive stuff) for
each iteration of some loop. Tricks like reusing a bunch of
temporary variables/buffers are easier when the whole
job is contained in a single function.
Lots of small functions bring the problem that each have to
be self-contained, they cannot all rely on having the calling
function manage a set of temporary variables for them. And passing
lots of temporary stuff as parameters is real ugly too. And so
each little function is made nice and robust and easy to
use - and much more costly when called a million times. :-/
Perhaps this is against "good OO design" but performance
matters too. :-)
Helge Hafting