Use copy ctor to return in a case whole string is being returned.
The intention was to optimize String::stripWhiteSpace for no-strip case
(without any leading or trailing white space removal).
copyFromUTF16 was used in any case previously and allocated duplicate
buffer for the same string - no implicit sharing.
Signed-off-by: Martin Flaska <martin.flaska@legrand.us>
String String::substr(unsigned int position, unsigned int n) const
{
- return String(d->data.substr(position, n));
+ if(position == 0 && n == size())
+ return *this;
+ else
+ return String(d->data.substr(position, n));
}
String &String::append(const String &s)