Skip to content
Snippets Groups Projects
Commit 55368223 authored by Tom Lane's avatar Tom Lane
Browse files

Tweak the tree descent loop in fsm_search_avail to not look at the

right child if it doesn't need to.  This saves some miniscule number
of cycles, but the ulterior motive is to avoid an optimization bug
known to exist in SCO's C compiler (and perhaps others?)
parent 253fa736
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/freespace/fsmpage.c,v 1.2 2008/10/07 21:10:11 tgl Exp $ * $PostgreSQL: pgsql/src/backend/storage/freespace/fsmpage.c,v 1.3 2008/12/10 17:11:18 tgl Exp $
* *
* NOTES: * NOTES:
* *
...@@ -243,17 +243,20 @@ fsm_search_avail(Buffer buf, uint8 minvalue, bool advancenext, ...@@ -243,17 +243,20 @@ fsm_search_avail(Buffer buf, uint8 minvalue, bool advancenext,
*/ */
while (nodeno < NonLeafNodesPerPage) while (nodeno < NonLeafNodesPerPage)
{ {
int leftnodeno = leftchild(nodeno); int childnodeno = leftchild(nodeno);
int rightnodeno = leftnodeno + 1;
bool leftok = (leftnodeno < NodesPerPage) && if (childnodeno < NodesPerPage &&
(fsmpage->fp_nodes[leftnodeno] >= minvalue); fsmpage->fp_nodes[childnodeno] >= minvalue)
bool rightok = (rightnodeno < NodesPerPage) && {
(fsmpage->fp_nodes[rightnodeno] >= minvalue); nodeno = childnodeno;
continue;
if (leftok) }
nodeno = leftnodeno; childnodeno++; /* point to right child */
else if (rightok) if (childnodeno < NodesPerPage &&
nodeno = rightnodeno; fsmpage->fp_nodes[childnodeno] >= minvalue)
{
nodeno = childnodeno;
}
else else
{ {
/* /*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment