Performance

- Optimizes indexing into pending.data for direct task access.
This commit is contained in:
Paul Beckingham 2013-11-03 14:02:11 -05:00
parent 2ce8f4a416
commit d211337315
2 changed files with 9 additions and 4 deletions

View file

@ -48,6 +48,8 @@ Features
+ Rewritten task-sync(5) man page, listing sync options and setup guidelines..
+ Now properly uses the libc version of uuid_create and uuid_to_string for
FreeBSD (thanks to Pietro Cerutti).
+ Performance improvements:
+ Optimizes indexing into pending.data for direct task access.
Bugs
+ #1195 Random seed not random enough - removed all random number code (thanks

View file

@ -112,12 +112,15 @@ bool TF2::get (int id, Task& task)
if (! _loaded_tasks)
load_tasks ();
std::vector <Task>::iterator i;
for (i = _tasks.begin (); i != _tasks.end (); ++i)
// This is an optimization. Since the 'id' is based on the line number of
// pending.data file, the task in question cannot appear earlier than line
// (id - 1) in the file. It can, however, appear significantly later because
// it is not known how recent a GC operation was run.
for (int i = id - 1; i < _tasks.size (); ++i)
{
if (i->id == id)
if (_tasks[i].id == id)
{
task = *i;
task = _tasks[i];
return true;
}
}