Minor code cleanup - pass by reference instead of value; instead of creating temp char arrays on each deck loop while building deck metadata, use an ostringstream when needed.

This commit is contained in:
wrenczes@gmail.com
2010-11-07 03:55:56 +00:00
parent 416617fc0d
commit b14e3808db
4 changed files with 38 additions and 46 deletions
+2 -5
View File
@@ -211,19 +211,17 @@ void DeckMenu::Add(int id, const char * text,string desc, bool forceFocus, DeckM
}
}
void DeckMenu::updateScroller()
{
// add all the items from the Tasks db.
TaskList *taskList = NEW TaskList();
TaskList taskList;
scroller->Reset();
for (vector<Task*>::iterator it = taskList->tasks.begin(); it!=taskList->tasks.end(); it++)
for (vector<Task*>::iterator it = taskList.tasks.begin(); it!=taskList.tasks.end(); it++)
{
ostringstream taskDescription;
taskDescription << "[ " << setw(4) << (*it)->getReward() << " / " << (*it)->getExpiration() << " ] " << (*it)->getDesc() << endl;
scroller->Add( taskDescription.str() );
}
SAFE_DELETE(taskList);
}
@@ -241,5 +239,4 @@ void DeckMenu::destroy(){
DeckMenu::~DeckMenu()
{
SAFE_DELETE(scroller);
}