mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Avoided unnecessary toLower string conversions
This commit is contained in:
parent
79134ba665
commit
53f7ae5d09
@ -286,34 +286,34 @@ int SoundFile::getFormatFromFilename(const std::string& filename)
|
||||
std::string ext = "wav";
|
||||
std::string::size_type pos = filename.find_last_of(".");
|
||||
if (pos != std::string::npos)
|
||||
ext = filename.substr(pos + 1);
|
||||
ext = toLower(filename.substr(pos + 1));
|
||||
|
||||
// Match every supported extension with its format constant
|
||||
if (toLower(ext) == "wav" ) return SF_FORMAT_WAV;
|
||||
if (toLower(ext) == "aif" ) return SF_FORMAT_AIFF;
|
||||
if (toLower(ext) == "aiff" ) return SF_FORMAT_AIFF;
|
||||
if (toLower(ext) == "au" ) return SF_FORMAT_AU;
|
||||
if (toLower(ext) == "raw" ) return SF_FORMAT_RAW;
|
||||
if (toLower(ext) == "paf" ) return SF_FORMAT_PAF;
|
||||
if (toLower(ext) == "svx" ) return SF_FORMAT_SVX;
|
||||
if (toLower(ext) == "nist" ) return SF_FORMAT_NIST;
|
||||
if (toLower(ext) == "voc" ) return SF_FORMAT_VOC;
|
||||
if (toLower(ext) == "sf" ) return SF_FORMAT_IRCAM;
|
||||
if (toLower(ext) == "w64" ) return SF_FORMAT_W64;
|
||||
if (toLower(ext) == "mat4" ) return SF_FORMAT_MAT4;
|
||||
if (toLower(ext) == "mat5" ) return SF_FORMAT_MAT5;
|
||||
if (toLower(ext) == "pvf" ) return SF_FORMAT_PVF;
|
||||
if (toLower(ext) == "xi" ) return SF_FORMAT_XI;
|
||||
if (toLower(ext) == "htk" ) return SF_FORMAT_HTK;
|
||||
if (toLower(ext) == "sds" ) return SF_FORMAT_SDS;
|
||||
if (toLower(ext) == "avr" ) return SF_FORMAT_AVR;
|
||||
if (toLower(ext) == "sd2" ) return SF_FORMAT_SD2;
|
||||
if (toLower(ext) == "flac" ) return SF_FORMAT_FLAC;
|
||||
if (toLower(ext) == "caf" ) return SF_FORMAT_CAF;
|
||||
if (toLower(ext) == "wve" ) return SF_FORMAT_WVE;
|
||||
if (toLower(ext) == "ogg" ) return SF_FORMAT_OGG;
|
||||
if (toLower(ext) == "mpc2k") return SF_FORMAT_MPC2K;
|
||||
if (toLower(ext) == "rf64" ) return SF_FORMAT_RF64;
|
||||
if (ext == "wav" ) return SF_FORMAT_WAV;
|
||||
if (ext == "aif" ) return SF_FORMAT_AIFF;
|
||||
if (ext == "aiff" ) return SF_FORMAT_AIFF;
|
||||
if (ext == "au" ) return SF_FORMAT_AU;
|
||||
if (ext == "raw" ) return SF_FORMAT_RAW;
|
||||
if (ext == "paf" ) return SF_FORMAT_PAF;
|
||||
if (ext == "svx" ) return SF_FORMAT_SVX;
|
||||
if (ext == "nist" ) return SF_FORMAT_NIST;
|
||||
if (ext == "voc" ) return SF_FORMAT_VOC;
|
||||
if (ext == "sf" ) return SF_FORMAT_IRCAM;
|
||||
if (ext == "w64" ) return SF_FORMAT_W64;
|
||||
if (ext == "mat4" ) return SF_FORMAT_MAT4;
|
||||
if (ext == "mat5" ) return SF_FORMAT_MAT5;
|
||||
if (ext == "pvf" ) return SF_FORMAT_PVF;
|
||||
if (ext == "xi" ) return SF_FORMAT_XI;
|
||||
if (ext == "htk" ) return SF_FORMAT_HTK;
|
||||
if (ext == "sds" ) return SF_FORMAT_SDS;
|
||||
if (ext == "avr" ) return SF_FORMAT_AVR;
|
||||
if (ext == "sd2" ) return SF_FORMAT_SD2;
|
||||
if (ext == "flac" ) return SF_FORMAT_FLAC;
|
||||
if (ext == "caf" ) return SF_FORMAT_CAF;
|
||||
if (ext == "wve" ) return SF_FORMAT_WVE;
|
||||
if (ext == "ogg" ) return SF_FORMAT_OGG;
|
||||
if (ext == "mpc2k") return SF_FORMAT_MPC2K;
|
||||
if (ext == "rf64" ) return SF_FORMAT_RF64;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -229,27 +229,27 @@ bool ImageLoader::saveImageToFile(const std::string& filename, const std::vector
|
||||
if (filename.size() > 3)
|
||||
{
|
||||
// Extract the extension
|
||||
std::string extension = filename.substr(filename.size() - 3);
|
||||
std::string extension = toLower(filename.substr(filename.size() - 3));
|
||||
|
||||
if (toLower(extension) == "bmp")
|
||||
if (extension == "bmp")
|
||||
{
|
||||
// BMP format
|
||||
if (stbi_write_bmp(filename.c_str(), size.x, size.y, 4, &pixels[0]))
|
||||
return true;
|
||||
}
|
||||
else if (toLower(extension) == "tga")
|
||||
else if (extension == "tga")
|
||||
{
|
||||
// TGA format
|
||||
if (stbi_write_tga(filename.c_str(), size.x, size.y, 4, &pixels[0]))
|
||||
return true;
|
||||
}
|
||||
else if(toLower(extension) == "png")
|
||||
else if (extension == "png")
|
||||
{
|
||||
// PNG format
|
||||
if (stbi_write_png(filename.c_str(), size.x, size.y, 4, &pixels[0], 0))
|
||||
return true;
|
||||
}
|
||||
else if (toLower(extension) == "jpg")
|
||||
else if (extension == "jpg")
|
||||
{
|
||||
// JPG format
|
||||
if (writeJpg(filename, pixels, size.x, size.y))
|
||||
|
Loading…
Reference in New Issue
Block a user