]> granicus.if.org Git - postgresql/commitdiff
Remove a couple of useless pstrdup() calls.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 10 Mar 2016 04:29:05 +0000 (23:29 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 10 Mar 2016 04:29:05 +0000 (23:29 -0500)
There's no point in pstrdup'ing the result of TextDatumGetCString,
since that's necessarily already a freshly-palloc'd C string.

These particular calls are unlikely to be of any consequence
performance-wise, but still they're a bad precedent that can confuse
future patch authors.

Noted by Chapman Flack.

src/backend/foreign/foreign.c

index 45180c7414dd58dc77fb11f1d2ba66b816fea22d..239849bb0b038b29d03b1d2887cbe6f53fb1539c 100644 (file)
@@ -121,14 +121,14 @@ GetForeignServer(Oid serverid)
                                                        tp,
                                                        Anum_pg_foreign_server_srvtype,
                                                        &isnull);
-       server->servertype = isnull ? NULL : pstrdup(TextDatumGetCString(datum));
+       server->servertype = isnull ? NULL : TextDatumGetCString(datum);
 
        /* Extract server version */
        datum = SysCacheGetAttr(FOREIGNSERVEROID,
                                                        tp,
                                                        Anum_pg_foreign_server_srvversion,
                                                        &isnull);
-       server->serverversion = isnull ? NULL : pstrdup(TextDatumGetCString(datum));
+       server->serverversion = isnull ? NULL : TextDatumGetCString(datum);
 
        /* Extract the srvoptions */
        datum = SysCacheGetAttr(FOREIGNSERVEROID,