Skip to content

Commit

Permalink
Cleanup usage of std::transform instead of Utils::uppered/lowered
Browse files Browse the repository at this point in the history
  • Loading branch information
frabert committed Sep 14, 2018
1 parent cd5e440 commit 7ed92f6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 24 deletions.
16 changes: 6 additions & 10 deletions src/audio/AudioWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ namespace World

Handle::SfxHandle AudioWorld::loadAudioVDF(const VDFS::FileIndex& idx, const std::string& name)
{
std::string ucname = name;
std::transform(ucname.begin(), ucname.end(), ucname.begin(), ::toupper);
std::string ucname = Utils::uppered(name);

// m_SoundMap contains all the sounds with C_SFX script definitions
Sound* snd = nullptr;
Expand Down Expand Up @@ -408,16 +407,13 @@ namespace World
{
return false;
}
else

if (m_playingSegment != loweredName)
{
if (m_playingSegment != loweredName)
{
m_musicContext->playSegment(m_Segments.at(loweredName), timing);
m_playingSegment = loweredName;
}
return true;
m_musicContext->playSegment(m_Segments.at(loweredName), timing);
m_playingSegment = loweredName;
}
return false;
return true;
}

bool AudioWorld::playMusicTheme(const std::string& name)
Expand Down
3 changes: 1 addition & 2 deletions src/components/Vob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ void ::Vob::broadcastTransformChange(VobInformation& vob)

void ::Vob::setVisual(VobInformation& vob, const std::string& _visual)
{
std::string visual = _visual;
std::transform(visual.begin(), visual.end(), visual.begin(), ::toupper);
std::string visual = Utils::uppered(_visual);

// Don't set twice
if (vob.visual && vob.visual->getName() == visual)
Expand Down
3 changes: 1 addition & 2 deletions src/content/AnimationAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ namespace Animations

inline Handle::AnimationHandle AnimationAllocator::allocate(const std::string& name)
{
std::string uname = name;
std::transform(uname.begin(), uname.end(), uname.begin(), ::toupper);
std::string uname = Utils::uppered(name);

auto h = m_Allocator.createObject();
m_AnimationsByName[uname] = h;
Expand Down
10 changes: 4 additions & 6 deletions src/content/AnimationLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ namespace Animations

Handle::AnimationDataHandle AnimationLibrary::loadMAN(const std::string& name)
{
std::string file_name = name + ".MAN";
std::transform(file_name.begin(), file_name.end(), file_name.begin(), ::toupper);
std::string file_name = Utils::uppered(name + ".MAN");

Handle::AnimationDataHandle h = m_World.getAnimationDataAllocator().getAnimationData(name);
if (h.isValid())
Expand Down Expand Up @@ -347,10 +346,9 @@ namespace Animations

std::string AnimationLibrary::makeQualifiedName(const std::string& mesh_lib, const std::string& overlay, const std::string& name)
{
std::string umesh_lib = mesh_lib, uoverlay = overlay, uname = name;
std::transform(umesh_lib.begin(), umesh_lib.end(), umesh_lib.begin(), ::toupper);
std::transform(uoverlay.begin(), uoverlay.end(), uoverlay.begin(), ::toupper);
std::transform(uname.begin(), uname.end(), uname.begin(), ::toupper);
std::string umesh_lib = Utils::uppered(mesh_lib),
uoverlay = Utils::uppered(overlay),
uname = Utils::uppered(name);

std::string qname;
if (uoverlay.find(umesh_lib) != 0)
Expand Down
6 changes: 2 additions & 4 deletions src/utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ std::list<std::string> Utils::getFilesInDirectory(const std::string& directory,
std::list<std::string> l;

forEachFile(directory, [&](const std::string& path, const std::string& name, const std::string& fext) {
std::string extlower = fext;
std::transform(extlower.begin(), extlower.end(), extlower.begin(), ::tolower);
std::string extlower = Utils::lowered(fext);

if (ext == "*" || extlower == ext)
l.push_back(path);
Expand Down Expand Up @@ -117,8 +116,7 @@ size_t Utils::getFileSize(const std::string& file)
std::string Utils::getCaseSensitivePath(const std::string& caseInsensitivePath, const std::string& prePath)
{
// Transform input path to lower
std::string pathLower = caseInsensitivePath;
std::transform(pathLower.begin(), pathLower.end(), pathLower.begin(), ::tolower);
std::string pathLower = Utils::lowered(caseInsensitivePath);

// Split the input-path at /
std::vector<std::string> parts = Utils::split(pathLower, "/\\");
Expand Down

0 comments on commit 7ed92f6

Please sign in to comment.