Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #65 from Tilka/nits
Small changes
  • Loading branch information
Parlane committed Feb 13, 2014
2 parents 88526be + 404624b commit 06329e2
Show file tree
Hide file tree
Showing 56 changed files with 205 additions and 234 deletions.
18 changes: 9 additions & 9 deletions Source/Core/Common/ArmEmitter.cpp
Expand Up @@ -206,23 +206,23 @@ void ARMXEmitter::ORI2R(ARMReg rd, ARMReg rs, u32 val, ARMReg scratch)

void ARMXEmitter::FlushLitPool()
{
for(std::vector<LiteralPool>::iterator it = currentLitPool.begin(); it != currentLitPool.end(); ++it) {
for(LiteralPool& pool : currentLitPool) {
// Search for duplicates
for(std::vector<LiteralPool>::iterator old_it = currentLitPool.begin(); old_it != it; ++old_it) {
if ((*old_it).val == (*it).val)
(*it).loc = (*old_it).loc;
for(LiteralPool& old_pool : currentLitPool) {
if (old_pool.val == pool.val)
pool.loc = old_pool.loc;
}

// Write the constant to Literal Pool
if (!(*it).loc)
if (!pool.loc)
{
(*it).loc = (s32)code;
Write32((*it).val);
pool.loc = (s32)code;
Write32(pool.val);
}
s32 offset = (*it).loc - (s32)(*it).ldr_address - 8;
s32 offset = pool.loc - (s32)pool.ldr_address - 8;

// Backpatch the LDR
*(u32*)(*it).ldr_address |= (offset >= 0) << 23 | abs(offset);
*(u32*)pool.ldr_address |= (offset >= 0) << 23 | abs(offset);
}
// TODO: Save a copy of previous pools in case they are still in range.
currentLitPool.clear();
Expand Down
29 changes: 13 additions & 16 deletions Source/Core/Common/BreakPoints.cpp
Expand Up @@ -8,19 +8,18 @@
#include "../Core/PowerPC/JitCommon/JitBase.h"

#include <sstream>
#include <algorithm>

bool BreakPoints::IsAddressBreakPoint(u32 _iAddress)
{
for (auto& bp : m_BreakPoints)
for (const TBreakPoint& bp : m_BreakPoints)
if (bp.iAddress == _iAddress)
return true;
return false;
}

bool BreakPoints::IsTempBreakPoint(u32 _iAddress)
{
for (auto& bp : m_BreakPoints)
for (const TBreakPoint& bp : m_BreakPoints)
if (bp.iAddress == _iAddress && bp.bTemporary)
return true;
return false;
Expand All @@ -29,7 +28,7 @@ bool BreakPoints::IsTempBreakPoint(u32 _iAddress)
BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const
{
TBreakPointsStr bps;
for (const auto& bp : m_BreakPoints)
for (const TBreakPoint& bp : m_BreakPoints)
{
if (!bp.bTemporary)
{
Expand All @@ -44,7 +43,7 @@ BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const

void BreakPoints::AddFromStrings(const TBreakPointsStr& bpstrs)
{
for (const auto& bpstr : bpstrs)
for (const std::string& bpstr : bpstrs)
{
TBreakPoint bp;
std::stringstream ss;
Expand Down Expand Up @@ -84,7 +83,7 @@ void BreakPoints::Add(u32 em_address, bool temp)

void BreakPoints::Remove(u32 em_address)
{
for (TBreakPoints::iterator i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i)
for (auto i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i)
{
if (i->iAddress == em_address)
{
Expand All @@ -100,12 +99,10 @@ void BreakPoints::Clear()
{
if (jit)
{
std::for_each(m_BreakPoints.begin(), m_BreakPoints.end(),
[](const TBreakPoint& bp)
{
jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4);
}
);
for (const TBreakPoint& bp : m_BreakPoints)
{
jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4);
}
}

m_BreakPoints.clear();
Expand All @@ -114,7 +111,7 @@ void BreakPoints::Clear()
MemChecks::TMemChecksStr MemChecks::GetStrings() const
{
TMemChecksStr mcs;
for (const auto& bp : m_MemChecks)
for (const TMemCheck& bp : m_MemChecks)
{
std::stringstream mc;
mc << std::hex << bp.StartAddress;
Expand All @@ -129,7 +126,7 @@ MemChecks::TMemChecksStr MemChecks::GetStrings() const

void MemChecks::AddFromStrings(const TMemChecksStr& mcstrs)
{
for (const auto& mcstr : mcstrs)
for (const std::string& mcstr : mcstrs)
{
TMemCheck mc;
std::stringstream ss;
Expand All @@ -156,7 +153,7 @@ void MemChecks::Add(const TMemCheck& _rMemoryCheck)

void MemChecks::Remove(u32 _Address)
{
for (TMemChecks::iterator i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i)
for (auto i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i)
{
if (i->StartAddress == _Address)
{
Expand All @@ -168,7 +165,7 @@ void MemChecks::Remove(u32 _Address)

TMemCheck *MemChecks::GetMemCheck(u32 address)
{
for (auto& bp : m_MemChecks)
for (TMemCheck& bp : m_MemChecks)
{
if (bp.bRange)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Common/CDUtils.cpp
Expand Up @@ -192,7 +192,7 @@ std::vector<std::string> cdio_get_devices ()
for (unsigned int j = checklist[i].num_min; j <= checklist[i].num_max; ++j)
{
std::string drive = StringFromFormat(checklist[i].format, j);
if ( (is_cdrom(drive.c_str(), NULL)) > 0 )
if ( (is_cdrom(drive, NULL)) > 0 )
{
drives.push_back(std::move(drive));
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Common/ChunkFile.h
Expand Up @@ -117,9 +117,9 @@ class PointerWrap
case MODE_WRITE:
case MODE_MEASURE:
case MODE_VERIFY:
for (auto itr = x.begin(); itr != x.end(); ++itr)
for (V& val : x)
{
Do(*itr);
Do(val);
}
break;
}
Expand Down
19 changes: 9 additions & 10 deletions Source/Core/Common/IniFile.cpp
Expand Up @@ -87,10 +87,9 @@ void IniFile::Section::Set(const std::string& key, const std::vector<std::string
{
std::string temp;
// Join the strings with ,
std::vector<std::string>::const_iterator it;
for (it = newValues.begin(); it != newValues.end(); ++it)
for (const std::string& value : newValues)
{
temp = (*it) + ",";
temp = value + ",";
}
// remove last ,
temp.resize(temp.length() - 1);
Expand Down Expand Up @@ -210,15 +209,15 @@ bool IniFile::Section::Delete(const std::string& key)

const IniFile::Section* IniFile::GetSection(const std::string& sectionName) const
{
for (const auto& sect : sections)
for (const Section& sect : sections)
if (!strcasecmp(sect.name.c_str(), sectionName.c_str()))
return (&(sect));
return 0;
}

IniFile::Section* IniFile::GetSection(const std::string& sectionName)
{
for (auto& sect : sections)
for (Section& sect : sections)
if (!strcasecmp(sect.name.c_str(), sectionName.c_str()))
return (&(sect));
return 0;
Expand All @@ -240,7 +239,7 @@ bool IniFile::DeleteSection(const std::string& sectionName)
Section* s = GetSection(sectionName);
if (!s)
return false;
for (std::vector<Section>::iterator iter = sections.begin(); iter != sections.end(); ++iter)
for (auto iter = sections.begin(); iter != sections.end(); ++iter)
{
if (&(*iter) == s)
{
Expand Down Expand Up @@ -399,21 +398,21 @@ bool IniFile::Save(const std::string& filename)
return false;
}

for (auto& section : sections)
for (const Section& section : sections)
{
if (section.keys_order.size() != 0 || section.lines.size() != 0)
out << "[" << section.name << "]" << std::endl;

if (section.keys_order.size() == 0)
{
for (auto s : section.lines)
for (const std::string& s : section.lines)
out << s << std::endl;
}
else
{
for (auto kvit = section.keys_order.begin(); kvit != section.keys_order.end(); ++kvit)
for (const std::string& kvit : section.keys_order)
{
auto pair = section.values.find(*kvit);
auto pair = section.values.find(kvit);
out << pair->first << " = " << pair->second << std::endl;
}
}
Expand Down
9 changes: 4 additions & 5 deletions Source/Core/Common/LogManager.cpp
Expand Up @@ -81,7 +81,7 @@ LogManager::LogManager()
m_consoleLog = new ConsoleListener();
m_debuggerLog = new DebuggerLogListener();

for (auto& container : m_Log)
for (LogContainer* container : m_Log)
{
container->SetEnable(true);
container->AddListener(m_fileLog);
Expand All @@ -102,7 +102,7 @@ LogManager::~LogManager()
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_debuggerLog);
}

for (auto& container : m_Log)
for (LogContainer* container : m_Log)
delete container;

delete m_fileLog;
Expand Down Expand Up @@ -168,10 +168,9 @@ void LogContainer::Trigger(LogTypes::LOG_LEVELS level, const char *msg)
{
std::lock_guard<std::mutex> lk(m_listeners_lock);

std::set<LogListener*>::const_iterator i;
for (i = m_listeners.begin(); i != m_listeners.end(); ++i)
for (LogListener* listener : m_listeners)
{
(*i)->Log(level, msg);
listener->Log(level, msg);
}
}

Expand Down
5 changes: 0 additions & 5 deletions Source/Core/Common/SymbolDB.h
Expand Up @@ -95,11 +95,6 @@ class SymbolDB
const XFuncMap &Symbols() const {return functions;}
XFuncMap &AccessSymbols() {return functions;}

// deprecated
XFuncMap::iterator GetIterator() { return functions.begin(); }
XFuncMap::const_iterator GetConstIterator() { return functions.begin(); }
XFuncMap::iterator End() { return functions.end(); }

void Clear(const char *prefix = "");
void List();
void Index();
Expand Down
11 changes: 4 additions & 7 deletions Source/Core/Common/SysConf.cpp
Expand Up @@ -25,8 +25,7 @@ SysConf::~SysConf()

void SysConf::Clear()
{
for (std::vector<SSysConfEntry>::const_iterator i = m_Entries.begin();
i < m_Entries.end() - 1; i++)
for (auto i = m_Entries.begin(); i < m_Entries.end() - 1; ++i)
delete [] i->data;
m_Entries.clear();
}
Expand Down Expand Up @@ -85,8 +84,7 @@ bool SysConf::LoadFromFileInternal(FILE *fh)
}

// Last offset is an invalid entry. We ignore it throughout this class
for (std::vector<SSysConfEntry>::iterator i = m_Entries.begin();
i < m_Entries.end() - 1; i++)
for (auto i = m_Entries.begin(); i < m_Entries.end() - 1; ++i)
{
SSysConfEntry& curEntry = *i;
f.Seek(curEntry.offset, SEEK_SET);
Expand Down Expand Up @@ -300,7 +298,7 @@ void SysConf::GenerateSysConf()
items[26].data[0] = 0x01;


for (auto& item : items)
for (const SSysConfEntry& item : items)
m_Entries.push_back(item);

File::CreateFullPath(m_FilenameDefault);
Expand Down Expand Up @@ -362,8 +360,7 @@ bool SysConf::SaveToFile(const char *filename)
{
File::IOFile f(filename, "r+b");

for (std::vector<SSysConfEntry>::iterator i = m_Entries.begin();
i < m_Entries.end() - 1; i++)
for (auto i = m_Entries.begin(); i < m_Entries.end() - 1; ++i)
{
// Seek to after the name of this entry
f.Seek(i->offset + i->nameLength + 1, SEEK_SET);
Expand Down
8 changes: 4 additions & 4 deletions Source/Core/Common/SysConf.h
Expand Up @@ -79,7 +79,7 @@ class SysConf
}

std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
for (; index < m_Entries.end() - 1; index++)
for (; index < m_Entries.end() - 1; ++index)
{
if (strcmp(index->name, sectionName) == 0)
break;
Expand All @@ -102,7 +102,7 @@ class SysConf
}

std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
for (; index < m_Entries.end() - 1; index++)
for (; index < m_Entries.end() - 1; ++index)
{
if (strcmp(index->name, sectionName) == 0)
break;
Expand All @@ -122,7 +122,7 @@ class SysConf
return false;

std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
for (; index < m_Entries.end() - 1; index++)
for (; index < m_Entries.end() - 1; ++index)
{
if (strcmp(index->name, sectionName) == 0)
break;
Expand All @@ -143,7 +143,7 @@ class SysConf
return false;

std::vector<SSysConfEntry>::iterator index = m_Entries.begin();
for (; index < m_Entries.end() - 1; index++)
for (; index < m_Entries.end() - 1; ++index)
{
if (strcmp(index->name, sectionName) == 0)
break;
Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Common/Timer.cpp
Expand Up @@ -3,6 +3,7 @@
// Refer to the license.txt file included.

#include <time.h>
#include <cinttypes>

#ifdef _WIN32
#include <Windows.h>
Expand Down Expand Up @@ -113,7 +114,7 @@ std::string Timer::GetTimeElapsedFormatted() const
// Hours
u32 Hours = Minutes / 60;

std::string TmpStr = StringFromFormat("%02i:%02i:%02i:%03lu",
std::string TmpStr = StringFromFormat("%02i:%02i:%02i:%03" PRIu64,
Hours, Minutes % 60, Seconds % 60, Milliseconds % 1000);
return TmpStr;
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/Core.cpp
Expand Up @@ -673,9 +673,9 @@ void UpdateTitle()
if (ElapseTime == 0)
ElapseTime = 1;

float FPS = Common::AtomicLoad(DrawnFrame) * 1000.0 / ElapseTime;
float VPS = DrawnVideo * 1000.0 / ElapseTime;
float Speed = DrawnVideo * (100 * 1000.0) / (VideoInterface::TargetRefreshRate * ElapseTime);
float FPS = (float) (Common::AtomicLoad(DrawnFrame) * 1000.0 / ElapseTime);
float VPS = (float) (DrawnVideo * 1000.0 / ElapseTime);
float Speed = (float) (DrawnVideo * (100 * 1000.0) / (VideoInterface::TargetRefreshRate * ElapseTime));

// Settings are shown the same for both extended and summary info
std::string SSettings = StringFromFormat("%s %s | %s | %s", cpu_core_base->GetName(), _CoreParameter.bCPUThread ? "DC" : "SC",
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/CoreTiming.cpp
Expand Up @@ -469,7 +469,7 @@ std::string GetScheduledEventsSummary()
if (!name)
name = "[unknown]";

text += StringFromFormat("%s : %li %08lx%08lx\n", name, ptr->time, ptr->userdata >> 32, ptr->userdata);
text += StringFromFormat("%s : %" PRIi64 " %016" PRIx64 "\n", name, ptr->time, ptr->userdata);
ptr = ptr->next;
}
return text;
Expand Down

0 comments on commit 06329e2

Please sign in to comment.