From a54367a3c015c7c7de9f77f2e792acac9f6c5b8b Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 8 Apr 2009 22:59:06 +0000 Subject: [PATCH] - 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. SVN r1532 (trunk) --- docs/rh-log.txt | 7 ++++++- src/p_maputl.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 492590474c..74c60b1f44 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 194d8950fc..775a408b09 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)