Re: [PATCH] backend: compare word-at-a-time in bcTruelen - Mailing list pgsql-hackers

From Jeremy Kerr
Subject Re: [PATCH] backend: compare word-at-a-time in bcTruelen
Date
Msg-id 200906162123.42513.jk@ozlabs.org
Whole thread Raw
In response to Re: [PATCH] backend: compare word-at-a-time in bcTruelen  (Greg Stark <gsstark@mit.edu>)
List pgsql-hackers
Hi all,

> That's correct. To check the alignment you would have to look at the
> actual pointer. I would suggest using the existing macros to handle
> alignment. Hm, though the only one I see offhand which is relevant is
> the moderately silly PointerIsAligned(). Still it would make the code
> clearer even if it's pretty simple.

Yes, the code (incorrectly) assumes that any multiple-of-4 index into 
the char array is aligned, and so the array itself must be aligned for 
this to work.

I'll rework the patch, testing the pointer alignment directly instead.

> Incidentally, the char foo[4] = {' ',' ',' ',' '} suggestion is, I
> think, bogus. There would be no alignment guarantee on that array.
> Personally I'm find with 0x20202020 with a comment explaining what it
> is.

The variable is called 'spaces', but I can add extra comments if 
preferred.

Cheers,


Jeremy




pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: machine-readable explain output
Next
From: Andres Freund
Date:
Subject: Re: machine-readable explain output