|
Boost Users : |
From: Chateauneu Remi (remi.chateauneu_at_[hidden])
Date: 2005-02-10 12:48:56
I'm working on an application with many std::string concatenations,
everywhere. This is consuming a lot of CPU resources, due to temporary
strings, memory allocation, etc... Due to the size of the existing code, it
is not possible to make big changes.
I tried first to transform these kind of expressions:
std::string a = b + c + d + e ;
... into ...
std::string a(b);
a += c ;
a += d ;
a += e ;
... and it is definitively faster, but not enough.
I've then worked on a method, just by adding a special object after the '='
sign, which transforms these concatenations into a two pass operation, the
first to calculate the total length and allocate the destination string, and
the second pass to actually copy the source strings into the destination.
One just need to re-write the concatenations this way :
std::string a = my_special_object() + b + c + d + e ;
But maybe I am reinventing the wheel. Is there in Boost, a way to speed up
this kind of operation ?
Thanks in advance.
-- DSL Komplett von GMX +++ Supergünstig und stressfrei einsteigen! AKTION "Kein Einrichtungspreis" nutzen: http://www.gmx.net/de/go/dsl
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net