Re: [CFReview] Red-Black Tree

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Mark Cave-Ayland <mark(dot)cave-ayland(at)siriusit(dot)co(dot)uk>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [CFReview] Red-Black Tree
Date: 2010-02-10 18:40:16
Message-ID: 4B72FD90.10404@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> So suppose at this point that step is the largest integer that can be
> represented...
>> ! step ++;
> Boom.
>> ! step>>= 1;
step>>= 1;
step ++'

Unboom?

>> !
>> ! while(step> 0) {
>> ! int i;
>>
>> ! for (i = step-1; i< nentry; i += 2 * step)
>
> And similarly here... if nentry is greater than maxint/2, then i += 2
> * step will overflow, no?

Agree, so
for (i = step - 1; i < nentry && i >= 0; i += step << 1 /* *2 */)

Also, rb_free is removed per Tom's comment. Can I commit the patch?
--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/

Attachment Content-Type Size
rbtree-0.13.gz application/x-tar 8.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2010-02-10 18:56:14 Re: [CFReview] Red-Black Tree
Previous Message Leonardo F 2010-02-10 18:30:35 Re: I: About "Our CLUSTER implementation is pessimal" patch