mirror of
https://github.com/taglib/taglib.git
synced 2025-07-17 20:44:20 -04:00
Reduce useless memory reallocation in String::upper().
This commit is contained in:
@ -62,8 +62,9 @@ namespace
|
||||
return false;
|
||||
}
|
||||
|
||||
const String upperKey = String(key).upper();
|
||||
for(size_t i = 0; invalidKeys[i] != 0; ++i) {
|
||||
if(String(key).upper() == invalidKeys[i])
|
||||
if(upperKey == invalidKeys[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ PropertyMap UnsynchronizedLyricsFrame::asProperties() const
|
||||
{
|
||||
PropertyMap map;
|
||||
String key = description().upper();
|
||||
if(key.isEmpty() || key.upper() == "LYRICS")
|
||||
if(key.isEmpty() || key == "LYRICS")
|
||||
map.insert("LYRICS", text());
|
||||
else
|
||||
map.insert("LYRICS:" + key, text());
|
||||
|
@ -170,7 +170,7 @@ PropertyMap UserUrlLinkFrame::asProperties() const
|
||||
{
|
||||
PropertyMap map;
|
||||
String key = description().upper();
|
||||
if(key.isEmpty() || key.upper() == "URL")
|
||||
if(key.isEmpty() || key == "URL")
|
||||
map.insert("URL", url());
|
||||
else
|
||||
map.insert("URL:" + key, url());
|
||||
|
@ -469,12 +469,11 @@ String & String::clear()
|
||||
String String::upper() const
|
||||
{
|
||||
String s;
|
||||
|
||||
static int shift = 'A' - 'a';
|
||||
s.d->data.reserve(size());
|
||||
|
||||
for(ConstIterator it = begin(); it != end(); ++it) {
|
||||
if(*it >= 'a' && *it <= 'z')
|
||||
s.d->data.push_back(*it + shift);
|
||||
s.d->data.push_back(*it + 'A' - 'a');
|
||||
else
|
||||
s.d->data.push_back(*it);
|
||||
}
|
||||
|
Reference in New Issue
Block a user