Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5536822

Browse files
committed
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?)
1 parent 253fa73 commit 5536822

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/backend/storage/freespace/fsmpage.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/freespace/fsmpage.c,v 1.2 2008/10/07 21:10:11 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/freespace/fsmpage.c,v 1.3 2008/12/10 17:11:18 tgl Exp $
1212
*
1313
* NOTES:
1414
*
@@ -243,17 +243,20 @@ fsm_search_avail(Buffer buf, uint8 minvalue, bool advancenext,
243243
*/
244244
while (nodeno < NonLeafNodesPerPage)
245245
{
246-
int leftnodeno = leftchild(nodeno);
247-
int rightnodeno = leftnodeno + 1;
248-
bool leftok = (leftnodeno < NodesPerPage) &&
249-
(fsmpage->fp_nodes[leftnodeno] >= minvalue);
250-
bool rightok = (rightnodeno < NodesPerPage) &&
251-
(fsmpage->fp_nodes[rightnodeno] >= minvalue);
252-
253-
if (leftok)
254-
nodeno = leftnodeno;
255-
else if (rightok)
256-
nodeno = rightnodeno;
246+
int childnodeno = leftchild(nodeno);
247+
248+
if (childnodeno < NodesPerPage &&
249+
fsmpage->fp_nodes[childnodeno] >= minvalue)
250+
{
251+
nodeno = childnodeno;
252+
continue;
253+
}
254+
childnodeno++; /* point to right child */
255+
if (childnodeno < NodesPerPage &&
256+
fsmpage->fp_nodes[childnodeno] >= minvalue)
257+
{
258+
nodeno = childnodeno;
259+
}
257260
else
258261
{
259262
/*

0 commit comments

Comments
 (0)