Re: Double linked list with one pointer - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Double linked list with one pointer
Date
Msg-id 200312070521.hB75LCi03231@candle.pha.pa.us
Whole thread Raw
In response to Re: Double linked list with one pointer  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
Andrew Dunstan wrote:
> 
> 
> Bruce Momjian wrote:
> 
> >Gaetano Mendola wrote:
> >  
> >
> >>I don't think the article is available online, alas, but you can find some
> >>related source code demonstrating the technique at:
> >>
> >>    http://www.semantics.org/tyr/tyr0_5/list.h
> >>    
> >>
> >
> >That certainly is an amazing idea.  You know the pointer you are coming
> >from so you can XOR to find the next pointer.
> >
> >I agree with a Tom that we don't have much use for double-link lists,
> >but is a nice idea.
> >  
> >
> 
> 
> I must confess that it strikes me as a really really horrid and ugly 
> hack - very likely to be error-prone and non-portable and undebuggable, 
> and for almost no saving worth having. But maybe that's just me.
> 
> In general I've been impressed with the quality of Pg code over the last 
> 6 months or so - I'd hate to see it polluted by something like this.

Agreed, I just thought it was neat and I hadn't realized it was
possible.

Also, I don't think the problems for doing this for swaping values
without a temp table is relevant.  In those cases, you are doing the
swap without a temp variable, and this is the problem, more than the XOR
itself, which is what we would use and use  real temp table.

--  Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
359-1001+  If your life is a hard drive,     |  13 Roberts Road +  Christ can be your backup.        |  Newtown Square,
Pennsylvania19073
 


pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: IDENT and IPv6 (was Re: [GENERAL] pg_hba.conf
Next
From: Tom Lane
Date:
Subject: Re: Double linked list with one pointer