Ticket #2127 - Performance and style improvements in scriptinterface.

No real behavior changes, only code maintenance.

Fixed signed/unsigned mismatch in EntityMap.h

This was SVN commit r13865.
This commit is contained in:
RedFox
2013-09-16 19:10:06 +00:00
parent 97912dd545
commit 5d9b2b95b0
6 changed files with 58 additions and 65 deletions
+15 -18
View File
@@ -33,7 +33,7 @@ const char* CDebuggingServer::header400 =
void CDebuggingServer::GetAllCallstacks(std::stringstream& response)
{
CScopeLock lock(m_Mutex);
response.str("");
response.str(std::string());
std::stringstream stream;
uint nbrCallstacksWritten = 0;
std::list<CThreadDebugger*>::iterator itr;
@@ -44,15 +44,13 @@ void CDebuggingServer::GetAllCallstacks(std::stringstream& response)
{
if ((*itr)->GetIsInBreak())
{
stream.str("");
std::string str = stream.str();
stream.str(std::string());
(*itr)->GetCallstack(stream);
str = stream.str();
if (stream.str() != "")
if ((int)stream.tellp() != 0)
{
if (nbrCallstacksWritten != 0)
response << ",";
response << "{" << "\"ThreadDebuggerID\" : " << (*itr)->GetID() << ", \"CallStack\" : " << stream.str() << "}";
response << "{" << "\"ThreadDebuggerID\" : " << (*itr)->GetID() << ", \"CallStack\" : " << stream << "}";
nbrCallstacksWritten++;
}
@@ -65,17 +63,17 @@ void CDebuggingServer::GetAllCallstacks(std::stringstream& response)
void CDebuggingServer::GetStackFrameData(std::stringstream& response, uint nestingLevel, uint threadDebuggerID, STACK_INFO stackInfoKind)
{
CScopeLock lock(m_Mutex);
response.str("");
response.str(std::string());
std::stringstream stream;
std::list<CThreadDebugger*>::iterator itr;
for (itr = m_ThreadDebuggers.begin(); itr != m_ThreadDebuggers.end(); ++itr)
{
if ( (*itr)->GetID() == threadDebuggerID && (*itr)->GetIsInBreak())
if ((*itr)->GetID() == threadDebuggerID && (*itr)->GetIsInBreak())
{
(*itr)->GetStackFrameData(stream, nestingLevel, stackInfoKind);
if (stream.str() != "")
if ((int)stream.tellp() != 0)
{
response << stream.str();
response << stream;
}
}
}
@@ -114,7 +112,7 @@ bool CDebuggingServer::SetNextDbgCmd(uint threadDebuggerID, DBGCMD dbgCmd)
std::list<CThreadDebugger*>::iterator itr;
for (itr = m_ThreadDebuggers.begin(); itr != m_ThreadDebuggers.end(); ++itr)
{
if ( (*itr)->GetID() == threadDebuggerID || threadDebuggerID == 0)
if ((*itr)->GetID() == threadDebuggerID || threadDebuggerID == 0)
{
if (DBG_CMD_NONE == (*itr)->GetNextDbgCmd() && (*itr)->GetIsInBreak())
{
@@ -188,7 +186,7 @@ void CDebuggingServer::EnumVfsJSFiles(std::stringstream& response)
{
VfsPath path = L"";
VfsPaths pathnames;
response.str("");
response.str(std::string());
std::vector<std::string> templates;
vfs::ForEachFile(g_VFS, "", AddFileResponse, (uintptr_t)&templates, L"*.js", vfs::DIR_RECURSIVE);
@@ -438,8 +436,8 @@ bool CDebuggingServer::GetWebArgs(struct mg_connection *conn, const struct mg_re
int len = mg_get_var(request_info->query_string, strlen(request_info->query_string), argName.c_str(), buf, ARRAY_SIZE(buf));
if (len < 0)
{
mg_printf(conn, "%s (no '%s')", header400, argName.c_str());
return false;
mg_printf(conn, "%s (no '%s')", header400, argName.c_str());
return false;
}
arg = atoi(buf);
return true;
@@ -492,7 +490,7 @@ void CDebuggingServer::UnRegisterScriptinterface(ScriptInterface* pScriptInterfa
void CDebuggingServer::GetThreadDebuggerStatus(std::stringstream& response)
{
CScopeLock lock(m_Mutex);
response.str("");
response.str(std::string());
std::list<CThreadDebugger*>::iterator itr;
response << "[";
@@ -529,11 +527,10 @@ void CDebuggingServer::ToggleBreakPoint(std::string filename, uint line)
// If the breakpoint isn't handled yet search the breakpoints registered in this class
std::list<CBreakPoint>* pBreakPoints = NULL;
double breakPointsLockID = AquireBreakPointAccess(&pBreakPoints);
std::list<CBreakPoint>::iterator itr;
// If set, delete
bool deleted = false;
for (itr = pBreakPoints->begin(); itr != pBreakPoints->end(); ++itr)
for (std::list<CBreakPoint>::iterator itr = pBreakPoints->begin(); itr != pBreakPoints->end(); ++itr)
{
if ((*itr).m_Filename == filename && (*itr).m_UserLine == line)
{
@@ -560,7 +557,7 @@ double CDebuggingServer::AquireBreakPointAccess(std::list<CBreakPoint>** breakPo
{
int ret;
ret = SDL_SemWait(m_BreakPointsSem);
ENSURE(0 == ret);
ENSURE(ret == 0);
(*breakPoints) = &m_BreakPoints;
m_BreakPointsLockID = timer_Time();
return m_BreakPointsLockID;