use ToLower() instead of calling std::transform explicitly all the time

This commit is contained in:
unK
2008-09-29 00:11:00 +02:00
parent dbe0480db5
commit 0a210a8896
6 changed files with 34 additions and 27 deletions

View File

@@ -18,7 +18,6 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <algorithm>
#include "helpers.h"
#include "tag_editor.h"
@@ -77,8 +76,8 @@ void UnlockStatusbar()
bool CaseInsensitiveSorting::operator()(string a, string b)
{
transform(a.begin(), a.end(), a.begin(), tolower);
transform(b.begin(), b.end(), b.begin(), tolower);
ToLower(a);
ToLower(b);
return a < b;
}
@@ -86,8 +85,8 @@ bool CaseInsensitiveSorting::operator()(Song *sa, Song *sb)
{
string a = sa->GetName();
string b = sb->GetName();
transform(a.begin(), a.end(), a.begin(), tolower);
transform(b.begin(), b.end(), b.begin(), tolower);
ToLower(a);
ToLower(b);
return a < b;
}
@@ -97,8 +96,8 @@ bool CaseInsensitiveSorting::operator()(const Item &a, const Item &b)
{
string sa = a.type == itSong ? a.song->GetName() : a.name;
string sb = b.type == itSong ? b.song->GetName() : b.name;
transform(sa.begin(), sa.end(), sa.begin(), tolower);
transform(sb.begin(), sb.end(), sb.begin(), tolower);
ToLower(sa);
ToLower(sb);
return sa < sb;
}
else

View File

@@ -71,7 +71,7 @@ void * GetArtistInfo(void *ptr)
delete strptr;
string filename = artist + ".txt";
transform(filename.begin(), filename.end(), filename.begin(), tolower);
ToLower(filename);
EscapeUnallowedChars(filename);
const string fullpath = artists_folder + "/" + filename;

View File

@@ -18,6 +18,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <algorithm>
#include "misc.h"
using std::stringstream;
@@ -27,6 +28,11 @@ int Abs(int num)
return (num < 0 ? -num : num);
}
void ToLower(string &s)
{
transform(s.begin(), s.end(), s.begin(), tolower);
}
int StrToInt(string str)
{
return atoi(str.c_str());

View File

@@ -30,6 +30,8 @@ using std::string;
int Abs(int);
void ToLower(string &);
int StrToInt(string);
string IntoStr(int);

View File

@@ -2945,13 +2945,13 @@ int main(int argc, char *argv[])
timer = time(NULL);
if (findme.empty())
continue;
transform(findme.begin(), findme.end(), findme.begin(), tolower);
ToLower(findme);
ShowMessage("Searching...");
for (int i = (wCurrent == mSearcher ? search_engine_static_options-1 : 0); i < wCurrent->Size(); i++)
{
string name = Window::OmitBBCodes(wCurrent->GetOption(i));
transform(name.begin(), name.end(), name.begin(), tolower);
ToLower(name);
if (name.find(findme) != string::npos && !wCurrent->IsStatic(i))
{
vFoundPositions.push_back(i);

View File

@@ -90,27 +90,27 @@ void Search(Song &s)
{
string t;
t = s.GetFile();
transform(t.begin(), t.end(), t.begin(), tolower);
ToLower(t);
s.SetFile(t);
t = s.GetTitle();
transform(t.begin(), t.end(), t.begin(), tolower);
ToLower(t);
s.SetTitle(t);
t = s.GetArtist();
transform(t.begin(), t.end(), t.begin(), tolower);
ToLower(t);
s.SetArtist(t);
t = s.GetAlbum();
transform(t.begin(), t.end(), t.begin(), tolower);
ToLower(t);
s.SetAlbum(t);
t = s.GetGenre();
transform(t.begin(), t.end(), t.begin(), tolower);
ToLower(t);
s.SetGenre(t);
t = s.GetComment();
transform(t.begin(), t.end(), t.begin(), tolower);
ToLower(t);
s.SetComment(t);
}
@@ -122,27 +122,27 @@ void Search(Song &s)
{
string t;
t = copy.GetName();
transform(t.begin(), t.end(), t.begin(), tolower);
ToLower(t);
copy.SetFile(t);
t = copy.GetTitle();
transform(t.begin(), t.end(), t.begin(), tolower);
ToLower(t);
copy.SetTitle(t);
t = copy.GetArtist();
transform(t.begin(), t.end(), t.begin(), tolower);
ToLower(t);
copy.SetArtist(t);
t = copy.GetAlbum();
transform(t.begin(), t.end(), t.begin(), tolower);
ToLower(t);
copy.SetAlbum(t);
t = copy.GetGenre();
transform(t.begin(), t.end(), t.begin(), tolower);
ToLower(t);
copy.SetGenre(t);
t = copy.GetComment();
transform(t.begin(), t.end(), t.begin(), tolower);
ToLower(t);
copy.SetComment(t);
}
else