Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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: rbtree-0.13.gz
Description: application/x-tar (8.6 KB)

In response to

Responses

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group