From: | Thom Brown <thom(at)linux(dot)com> |
---|---|
To: | Magnus Hagander <magnus(at)hagander(dot)net> |
Cc: | PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Why assignment before return? |
Date: | 2010-08-20 12:16:44 |
Message-ID: | AANLkTik7vVPmzS7xbAYX9v_kQqN=evXoASS5gMW94BXd@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 20 August 2010 12:46, Magnus Hagander <magnus(at)hagander(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Grittner | 2010-08-20 12:28:50 | Re: Avoiding deadlocks ... |
Previous Message | Max Bowsher | 2010-08-20 12:11:37 | Re: git: uh-oh |