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

Re: [CFReview] Red-Black Tree

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Teodor Sigaev <teodor(at)sigaev(dot)ru>
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:56:21
Message-ID: 603c8f071002101056t2c0e5d1axfb39a31c08dbe5cb@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
2010/2/10 Teodor Sigaev <teodor(at)sigaev(dot)ru>:
>> So suppose at this point that step is the largest integer that can be
>> represented...
>>>
>>> !       step ++;
>>
>> Boom.
>>>
>>> !       step>>= 1;
>
> step>>= 1;
> step ++'
>
> Unboom?

Yeah, that'll work.

>>> !
>>> !       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 */)

I don't think you should do it this way.  I can't immediately say
whether it's safe on all platforms, but it's certainly not clear.
Just put the test at the bottom of the loop the way I did it (after
fixing whatever I screwed up).

> Also, rb_free is removed per Tom's comment. Can I commit  the patch?

Pending the above, go for it.

...Robert

In response to

pgsql-hackers by date

Next:From: Robert HaasDate: 2010-02-10 18:57:13
Subject: Re: Some belated patch review for "Buffers" explain analyze patch
Previous:From: Alvaro HerreraDate: 2010-02-10 18:56:14
Subject: Re: [CFReview] Red-Black Tree

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