From 7c59e81de9ebed9e46b410e59d4c455715e33d55 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 10 Dec 2008 17:11:18 +0000 Subject: [PATCH] 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?) --- src/backend/storage/freespace/fsmpage.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/backend/storage/freespace/fsmpage.c b/src/backend/storage/freespace/fsmpage.c index fcb3b80338..ad9945cf90 100644 --- a/src/backend/storage/freespace/fsmpage.c +++ b/src/backend/storage/freespace/fsmpage.c @@ -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 { /* -- 2.39.5