aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-12-10 17:11:18 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-12-10 17:11:18 +0000
commit55368223cde4f19b4cd97eff7ea82b4a85a7a04c (patch)
tree6ec70410ddceee76ab832268114ff466f425ac21
parent253fa736b978f298746763ef3113282f32b9f475 (diff)
downloadpostgresql-55368223cde4f19b4cd97eff7ea82b4a85a7a04c.tar.gz
postgresql-55368223cde4f19b4cd97eff7ea82b4a85a7a04c.zip
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?)
-rw-r--r--src/backend/storage/freespace/fsmpage.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/backend/storage/freespace/fsmpage.c b/src/backend/storage/freespace/fsmpage.c
index 3a25c959299..a4479e88c07 100644
--- a/src/backend/storage/freespace/fsmpage.c
+++ b/src/backend/storage/freespace/fsmpage.c
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* 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:
*
@@ -243,17 +243,20 @@ fsm_search_avail(Buffer buf, uint8 minvalue, bool advancenext,
*/
while (nodeno < NonLeafNodesPerPage)
{
- int leftnodeno = leftchild(nodeno);
- int rightnodeno = leftnodeno + 1;
- bool leftok = (leftnodeno < NodesPerPage) &&
- (fsmpage->fp_nodes[leftnodeno] >= minvalue);
- bool rightok = (rightnodeno < NodesPerPage) &&
- (fsmpage->fp_nodes[rightnodeno] >= minvalue);
-
- if (leftok)
- nodeno = leftnodeno;
- else if (rightok)
- nodeno = rightnodeno;
+ int childnodeno = leftchild(nodeno);
+
+ if (childnodeno < NodesPerPage &&
+ fsmpage->fp_nodes[childnodeno] >= minvalue)
+ {
+ nodeno = childnodeno;
+ continue;
+ }
+ childnodeno++; /* point to right child */
+ if (childnodeno < NodesPerPage &&
+ fsmpage->fp_nodes[childnodeno] >= minvalue)
+ {
+ nodeno = childnodeno;
+ }
else
{
/*