Skip to content

Commit

Permalink
Use sv_inc() for the env de-dup hash in S_init_postdump_symbols().
Browse files Browse the repository at this point in the history
This replaces an hv_exists/hv_store pair with a single LVALUE hv_fetch.
  • Loading branch information
nwc10 committed Aug 23, 2021
1 parent 5fe1e1c commit fc0034a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions perl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4636,6 +4636,7 @@ S_init_postdump_symbols(pTHX_ int argc, char **argv, char **env)
* any meaningful speedup, and might well add bugs. */

if (hv_exists(hv, old_var, nlen)) {
SV **dup;
const char *name = savepvn(old_var, nlen);

/* make sure we use the same value as getenv(), otherwise code that
Expand All @@ -4644,10 +4645,10 @@ S_init_postdump_symbols(pTHX_ int argc, char **argv, char **env)
sv = newSVpv(PerlEnv_getenv(name), 0);

/* keep a count of the dups of this name so we can de-dup environ later */
if (hv_exists(dups, name, nlen))
++SvIVX(*hv_fetch(dups, name, nlen, 0));
else
(void)hv_store(dups, name, nlen, newSViv(1), 0);
dup = hv_fetch(dups, name, nlen, TRUE);
if (*dup) {
sv_inc(*dup);
}

Safefree(name);
}
Expand Down

0 comments on commit fc0034a

Please sign in to comment.