On Fri, Jul 31, 2020 at 1:00 PM Andres Freund <andres@anarazel.de> wrote:
> > Perhaps we could add a comment about this, e.g.
> > Marking these pointers with pg_restrict tells the compiler that str
> > and str->data can't overlap, which may allow the compiler to optimize
> > better when this code is inlined. For example, it may be possible to
> > keep str->data in a register across consecutive appendStringInfoString
> > operations.
> >
> > Since pg_restrict is not widely used, I think it's worth adding this
> > kind of annotation, lest other hackers get confused. I'm probably not
> > the only one who isn't on top of this.
>
> Would it make more sense to have a bit of an explanation at
> pg_restrict's definition, instead of having it at (eventually) multiple
> places?
I think, at least for the first few, it might be better to have a more
specific explanation at the point of use, as it may be easier to
understand in specific cases than in general. I imagine this only
really makes sense for places that are pretty hot.
> Ah, I misunderstood. Yea, there's no reason not to do that.
OK, then I vote for that version, as I think it looks nicer.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company