diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 492590474..74c60b1f4 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,9 @@ -April 7, 2009 (Changes by Graf Zahl) +April 8, 2009 +- Performance optimization for FBlockThingsIterator::Next(): Actors that + exist in only one block don't need to be added to the CheckArray or + scanned for in it. + +April 7, 2009 (Changes by Graf Zahl) - added some default definitions for constants that may miss in some headers. - replaced __va_copy with va_copy per Chris's suggestion. - replaced #include with #include where possible. diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 194d8950f..775a408b0 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -830,15 +830,20 @@ void FBlockThingsIterator::StartBlock(int x, int y) AActor *FBlockThingsIterator::Next() { - while (true) + for (;;) { while (block != NULL) { AActor *me = block->Me; + FBlockNode *mynode = block; int i; block = block->NextActor; // Don't recheck things that were already checked + if (mynode->NextBlock == NULL && mynode->PrevBlock == &me->BlockNode) + { // This actor doesn't span blocks, so we know it can only ever be checked once. + return me; + } for (i = (int)CheckArray.Size() - 1; i >= checkindex; --i) { if (CheckArray[i] == me)