summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2011-04-07 11:44:15 -0700
committerFather Chrysostomos <sprout@cpan.org>2011-04-07 12:11:33 -0700
commit7d779b236fc2cb0c2dbe324bda777c76494a71a5 (patch)
treeb266452ad87b1699b90ab70c684eb59afdbf4ded /pp_hot.c
parenta778d1f5c1a446254887ec8addb0044ba74ea05a (diff)
downloadperl-7d779b236fc2cb0c2dbe324bda777c76494a71a5.tar.gz
[perl #87708] $tied == $tied
This is only part of #87708. This fixes the + operator outside of any ‘use integer’ scope when the same tied scalar is used for both operands and returns two different values. Before this commit, get-magic would be called only once and the same value used. In 5.12.x it just worked. I tried modifying pp_eq throughout to take this case into account, but it made the most common cases slightly slower, presumably because of the extra checks. So this follows the same temp sv method that I used for pp_add (in 4c3ac4b and 837c879), which, though slowing down this edge cases due to the extra allocation, leaves the most common cases just as fast. (And, in case my benchmarks were unreliably [not unlikely], this method is also safer, as it has less chance of getting different code paths wrong.)
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/pp_hot.c b/pp_hot.c
index 06b837bf15..b6b8851325 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -342,6 +342,18 @@ PP(pp_eq)
RETURN;
}
#endif
+ if (TOPs == TOPm1s && SvGMAGICAL(TOPs)) {
+ SV * const svl = sv_newmortal();
+ /* Print the uninitialized warning now, so it includes the vari-
+ able name. */
+ if (!SvOK(TOPs)) {
+ if (ckWARN(WARN_UNINITIALIZED)) report_uninit(TOPs);
+ sv_setiv(svl,0);
+ }
+ else sv_setsv_flags(svl, TOPs, 0);
+ SvGETMAGIC(TOPs);
+ TOPm1s = svl;
+ }
#ifdef PERL_PRESERVE_IVUV
SvIV_please_nomg(TOPs);
if (SvIOK(TOPs)) {