Re: Duplicated assignment of slot_name in walsender.c

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Duplicated assignment of slot_name in walsender.c
Дата
Msg-id 47814.1445469069@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Duplicated assignment of slot_name in walsender.c  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> Andres Freund wrote:
>> for another every decent compiler can optimize those away. Note that
>> those duplicate strlen() calls are there in a lot of places in
>> walsender.c

> It can?  Tom has repeatedly argue the opposite, in the past.

I'm prepared to believe that *some* compilers do that, but I think it's
doubtful that they all do.  Even if they do, it would have to be a very
tightly constrained optimization, since the compiler would have to be able
to prove that there is no way for the referenced string to get changed
between the two call sites.  That would likely mean that some places where
you think this will happen will actually end up doing the strlen() twice.

I'm willing to buy the argument that performance doesn't matter in this
particular context; but if we think it does, I'd rather see us explicitly
save and re-use the strlen() result, so that the code behaves the same on
every platform.
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Thomas Munro
Дата:
Сообщение: Re: bugs and bug tracking
Следующее
От: Petr Jelinek
Дата:
Сообщение: Re: WIP: Rework access method interface