Re: [PATCH] binary heap implementation

From: Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] binary heap implementation
Date: 2012-11-16 01:56:25
Message-ID: 20121116015625.GA29765@toroid.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At 2012-11-15 10:11:58 -0500, robertmhaas(at)gmail(dot)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 Content-Type Size
binaryheap.diff text/x-diff 17.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2012-11-16 02:12:29 Re: Doc patch making firm recommendation for setting the value of commit_delay
Previous Message Craig Ringer 2012-11-16 01:43:27 Re: feature proposal - triggers by semantics