mirror of
https://github.com/taglib/taglib.git
synced 2025-07-18 13:04:18 -04:00
Merge pull request #778 from martin-flaska/optimization
String::substr optimization
This commit is contained in:
@ -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)
|
||||
|
@ -112,6 +112,9 @@ public:
|
||||
CPPUNIT_ASSERT(String(" foo ").stripWhiteSpace() == String("foo"));
|
||||
CPPUNIT_ASSERT(String("foo ").stripWhiteSpace() == String("foo"));
|
||||
CPPUNIT_ASSERT(String(" foo").stripWhiteSpace() == String("foo"));
|
||||
CPPUNIT_ASSERT(String("foo").stripWhiteSpace() == String("foo"));
|
||||
CPPUNIT_ASSERT(String("f o o").stripWhiteSpace() == String("f o o"));
|
||||
CPPUNIT_ASSERT(String(" f o o ").stripWhiteSpace() == String("f o o"));
|
||||
|
||||
CPPUNIT_ASSERT(memcmp(String("foo").data(String::Latin1).data(), "foo", 3) == 0);
|
||||
CPPUNIT_ASSERT(memcmp(String("f").data(String::Latin1).data(), "f", 1) == 0);
|
||||
|
Reference in New Issue
Block a user