8000 Remove a couple of useless pstrdup() calls. · postgrespro/postgres@cc40211 · GitHub
[go: up one dir, main page]

Skip to content
  • Commit cc40211

    Browse files
    committed
    Remove a couple of useless pstrdup() calls.
    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.
    1 parent 1d4a0ab commit cc40211

    File tree

    1 file changed

    +2
    -2
    lines changed

    1 file changed

    +2
    -2
    lines changed

    src/backend/foreign/foreign.c

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -121,14 +121,14 @@ GetForeignServer(Oid serverid)
    121121
    tp,
    122122
    Anum_pg_foreign_server_srvtype,
    123123
    &isnull);
    124-
    server->servertype = isnull ? NULL : pstrdup(TextDatumGetCString(datum));
    124+
    server->servertype = isnull ? NULL : TextDatumGetCString(datum);
    125125

    126126
    /* Extract server version */
    127127
    datum = SysCacheGetAttr(FOREIGNSERVEROID,
    128128
    tp,
    129129
    Anum_pg_foreign_server_srvversion,
    130130
    &isnull);
    131-
    server->serverversion = isnull ? NULL : pstrdup(TextDatumGetCString(datum));
    131+
    server->serverversion = isnull ? NULL : TextDatumGetCString(datum);
    132132

    133133
    /* Extract the srvoptions */
    134134
    datum = SysCacheGetAttr(FOREIGNSERVEROID,

    0 commit comments

    Comments
     (0)
    0