mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
tstring: String::substr optimization when returning itself as a substring
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>
This commit is contained in:
parent
6cfb11bb12
commit
c9a0754e3b
@ -447,7 +447,10 @@ bool String::startsWith(const String &s) const
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user