aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2013-05-01 12:37:24 +0200
committerSebastian Geerken <devnull@localhost>2013-05-01 12:37:24 +0200
commit470d98eada6329db4c3d8442240d9f9bec920ec9 (patch)
tree5366777bf10249e2224802d85c27d18d613c8605
parentc2c9fc9b3aea2c05cdc3137f2badfbeb0c871633 (diff)
Splitting up findFloatIndex (mainly for profiling).
-rw-r--r--dw/outofflowmgr.cc88
-rw-r--r--dw/outofflowmgr.hh2
2 files changed, 49 insertions, 41 deletions
diff --git a/dw/outofflowmgr.cc b/dw/outofflowmgr.cc
index 667a6d16..01bd4b9a 100644
--- a/dw/outofflowmgr.cc
+++ b/dw/outofflowmgr.cc
@@ -171,47 +171,9 @@ int OutOfFlowMgr::SortedFloatsVector::findFloatIndex (Textblock *lastGB,
// Float found with the same generator.
//printf (" => %d (same generator)\n", lastFloat->index);
return lastFloat->index;
- } else {
- // No float until "lastExtIndex"; search backwards in the
- // list of text blocks.
- int last = -1; // If nothing is found.
-
- // If not allocated, the only list to search is the GB
- // list, which has been searched already.
- if (oofm->wasAllocated (lastGB)) {
- for (int index = tbInfo->index - 1; last == -1 && index >= 0;
- index--) {
- TBInfo *prev = oofm->tbInfos->get (index);
- assert (index == prev->index);
- SortedFloatsVector *prevList =
- side == LEFT ? prev->leftFloatsGB : prev->rightFloatsGB;
- // Even if each GB list contains at least one
- // elemenent (otherwise it would not have been
- // created), this one element may be in the wrong
- // (i. e. opposite) list. So, this list may be
- // empty. Also, ignore floats which are not yet in
- // the CB list. (Latter may be more efficient.)
- for (int j = prevList->size() - 1;
- last == -1 && j >= 0; j--) {
- Float *lastFloat = prevList->get (j);
- if (lastFloat->inCBList) {
- //printf (" previous generator %p, index = %d; %s "
- // "list has %d elements\n",
- // prev->textblock, prev->index,
- // side == LEFT ? "left" : "right",
- // prevList->size());
- //printf (" lastFloat: %s\n",
- // lastFloat->toString ());
- last = lastFloat->index;
- }
- }
- // If no appropriate float found, continue.
- }
- }
-
- //printf (" => %d (other generator)\n", last);
- return last;
- }
+ } else
+ return findFloatIndexBackwards (tbInfo->index, lastGB,
+ lastExtIndex);
} else {
// "lastGB" not yet registered. TODO Correct?
//printf (" => %d (last GB not registered)\n", size () - 1);
@@ -223,6 +185,50 @@ int OutOfFlowMgr::SortedFloatsVector::findFloatIndex (Textblock *lastGB,
}
}
+int OutOfFlowMgr::SortedFloatsVector::findFloatIndexBackwards(int tbInfoIndex,
+ Textblock *lastGB,
+ int lastExtIndex)
+{
+ // No float until "lastExtIndex"; search backwards in the
+ // list of text blocks.
+ int last = -1; // If nothing is found.
+
+ // If not allocated, the only list to search is the GB
+ // list, which has been searched already.
+ if (oofm->wasAllocated (lastGB)) {
+ for (int index = tbInfoIndex - 1; last == -1 && index >= 0;
+ index--) {
+ TBInfo *prev = oofm->tbInfos->get (index);
+ assert (index == prev->index);
+ SortedFloatsVector *prevList =
+ side == LEFT ? prev->leftFloatsGB : prev->rightFloatsGB;
+ // Even if each GB list contains at least one elemenent
+ // (otherwise it would not have been created), this one
+ // element may be in the wrong (i. e. opposite) list. So,
+ // this list may be empty. Also, ignore floats which are not
+ // yet in the CB list. (Latter may be more efficient.)
+ for (int j = prevList->size() - 1;
+ last == -1 && j >= 0; j--) {
+ Float *lastFloat = prevList->get (j);
+ if (lastFloat->inCBList) {
+ //printf (" previous generator %p, index = %d; %s "
+ // "list has %d elements\n",
+ // prev->textblock, prev->index,
+ // side == LEFT ? "left" : "right",
+ // prevList->size());
+ //printf (" lastFloat: %s\n",
+ // lastFloat->toString ());
+ last = lastFloat->index;
+ }
+ }
+ // If no appropriate float found, continue.
+ }
+ }
+
+ //printf (" => %d (other generator)\n", last);
+ return last;
+}
+
int OutOfFlowMgr::SortedFloatsVector::find (Textblock *textblock, int y,
int start, int end)
{
diff --git a/dw/outofflowmgr.hh b/dw/outofflowmgr.hh
index 7c9d6b75..eafec01e 100644
--- a/dw/outofflowmgr.hh
+++ b/dw/outofflowmgr.hh
@@ -94,6 +94,8 @@ private:
{ this->oofm = oofm; this->side = side; this->type = type; }
int findFloatIndex (Textblock *lastGB, int lastExtIndex);
+ int findFloatIndexBackwards (int tbInfoIndex, Textblock *lastGB,
+ int lastExtIndex);
int find (Textblock *textblock, int y, int start, int end);
int findFirst (Textblock *textblock, int y, int h, Textblock *lastGB,
int lastExtIndex);