Re: Why assignment before return?
От | Thom Brown |
---|---|
Тема | Re: Why assignment before return? |
Дата | |
Msg-id | AANLkTik7vVPmzS7xbAYX9v_kQqN=evXoASS5gMW94BXd@mail.gmail.com обсуждение исходный текст |
Ответ на | Why assignment before return? (Magnus Hagander <magnus@hagander.net>) |
Список | pgsql-hackers |
On 20 August 2010 12:46, Magnus Hagander <magnus@hagander.net> wrote: > This code-pattern appears many times in pgstatfuncs.c: > > Datum > pg_stat_get_blocks_fetched(PG_FUNCTION_ARGS) > { > Oid relid = PG_GETARG_OID(0); > int64 result; > PgStat_StatTabEntry *tabentry; > > if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) > result = 0; > else > result = (int64) (tabentry->blocks_fetched); > > PG_RETURN_INT64(result); > } > > > Why do we assign this to "result" and then return, why not just: > if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL) > PG_RETURN_INT64(0); > else > PG_RETURN_INT64(tabentry->blocks_fetched); > > > -- And then drop the "int64 result;" declaration as a result. -- Thom Brown Registered Linux user: #516935
В списке pgsql-hackers по дате отправления: