develooper Front page | perl.perl5.porters | Postings from October 2000

pp_add -> pp_i_add efficiency hack?

Thread Next
Simon Cozens
October 5, 2000 03:07
pp_add -> pp_i_add efficiency hack?
Message ID:
So, I'm trying to describe what an PVIV is, and the way to do that is to
generate one. OK, so...

% ./perl -Ilib -MDevel::Peek -e '$a="12";$a+=1; Dump($a)'
SV = PVNV(0x80f3c98) at 0x80fcf30
  REFCNT = 1
  IV = 0
  NV = 13
  PV = 0x8101b40 "12"\0
  CUR = 2
  LEN = 3

Argh. Hang on, I didn't do anything floating point. Why has it upgraded to

We have two addition ops: one for integers, (pp_i_add) and one for 
non-integers. (pp_add) If "use integer" is in force, Perl can change
pp_add to pp_i_add at compile time, during the constant-folding stage.
Otherwise, at runtime, you have to go through pp_add which pops NVs off
the stack. This means that your SV gets upgraded to PVNV, possibly 

Would it be an efficiency hack to say the moral equivalent of

    if(SvIOK(left) && SvIOK(right))

and save the upgrade?

"I will make no bargains with terrorist hardware."
-- Peter da Silva

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About