From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
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 13:10:51 |
Message-ID: | 15496.1282309851@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Magnus Hagander <magnus(at)hagander(dot)net> writes:
> 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);
> }
I see nothing wrong with that style. Reducing it as you propose
probably wouldn't change the emitted code at all, and what it would
do is reduce flexibility. For instance, if we ever needed to add
additional operations just before the RETURN (releasing a lock on
the tabentry, perhaps) we'd just have to undo the "improvement".
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Joel Jacobson | 2010-08-20 13:11:11 | Deadlock bug |
Previous Message | Magnus Hagander | 2010-08-20 13:04:38 | Re: git: uh-oh |