Subject: | Useless creation of a variable |
Here,
https://metacpan.org/source/TOBYINK/Class-XSConstructor-0.007/XSConstructor.xs#L94
what's the point of creating val3? You've already copied the variable into val2, then you create another instance of the same variable, then you mark it to have its reference count decremented. Why not just use the existing val2 and not decrement the refcount?
Dist::Zilla doesn't work for me so I was unable to try it on your repository, but editing the code from the distribution, using val2 seems not to create problems.
This is the code from version 0.006 which I downloaded yesterday:
if (hv_exists(args, keyname, keylen)) {
SV** val = hv_fetch(args, keyname, keylen, 0);
SV* val2 = newSVsv(*val);
/* optional isa check */
if (hv_exists(ISA_attrs, keyname, keylen)) {
SV** const check = hv_fetch(ISA_attrs, keyname, keylen, 0);
SV* result;
dSP;
int count;
ENTER;
SAVETMPS;
PUSHMARK(SP);
EXTEND(SP, 1);
PUSHs(val2);
PUTBACK;
count = call_sv(*check, G_SCALAR);
result = POPs;