Re: [PATCH] binary heap implementation - Mailing list pgsql-hackers

From Abhijit Menon-Sen
Subject Re: [PATCH] binary heap implementation
Date
Msg-id 20121116015625.GA29765@toroid.org
Whole thread Raw
In response to Re: [PATCH] binary heap implementation  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: [PATCH] binary heap implementation
List pgsql-hackers
At 2012-11-15 10:11:58 -0500, robertmhaas@gmail.com wrote:
>
> It could use a run through pgindent.

Done.

> I think you want Assert(heap->size < heap->space).

Of course. Thanks for catching that.

> Project style is to omit braces for a single-line body.

I've removed most of them. In the few cases where one branch of an
if/else would have a one-line body and the other would not, I chose
to rewrite the code to avoid the problem (because, like Andrew, I
hate having to do that).

I wasn't sure how to present the following:

        if (right_off < heap->size &&
            heap->compare(&heap->nodes[node_off],
                          &heap->nodes[right_off]) < 0)
        {
            /* swap with the larger child */
            if (!swap_off ||
                heap->compare(&heap->nodes[left_off],
                              &heap->nodes[right_off]) < 0)
            {
                swap_off = right_off;
            }
        }

…so I left it alone. If you want me to remove the inner braces and
resubmit, despite the multi-line condition, let me know.

I didn't know which header comments Álvaro meant I should remove,
so I haven't done that either. I did remove the TESTBINHEAP stuff,
though.

I have attached the updated patch here. Thanks for your review.

-- Abhijit

Attachment

pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
Subject: Re: feature proposal - triggers by semantics
Next
From: Peter Geoghegan
Date:
Subject: Re: Doc patch making firm recommendation for setting the value of commit_delay