diff options
author | Salvador FandiƱo <sfandino@yahoo.com> | 2005-06-05 04:25:00 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2005-06-05 11:14:41 +0000 |
commit | 83a44efe0f25f926e57d27d2045131cfcd0373de (patch) | |
tree | b578c78e945a13dfc734eaec69c10ec7b610f958 /pp_sort.c | |
parent | 2c0c5f92cc8c83f85f490c4724df41382ded08d0 (diff) | |
download | perl-83a44efe0f25f926e57d27d2045131cfcd0373de.tar.gz |
PATCH for [perl #36043] '@foo = sort { $a <=> $b } @bar' uses too much memory
Message-ID: <20050605022436.21982.qmail@lists.develooper.com>
p4raw-id: //depot/perl@24708
Diffstat (limited to 'pp_sort.c')
-rw-r--r-- | pp_sort.c | 39 |
1 files changed, 31 insertions, 8 deletions
@@ -1593,17 +1593,40 @@ PP(pp_sort) sortsvp = S_sortsv_desc; } - /* shuffle stack down, removing optional initial cv (p1!=p2), plus any - * nulls; also stringify any args */ + /* shuffle stack down, removing optional initial cv (p1!=p2), plus + * any nulls; also stringify or converting to integer or number as + * required any args */ for (i=max; i > 0 ; i--) { if ((*p1 = *p2++)) { /* Weed out nulls. */ SvTEMP_off(*p1); - if (!PL_sortcop && !SvPOK(*p1)) { - STRLEN n_a; - if (SvAMAGIC(*p1)) - overloading = 1; - else - (void)sv_2pv(*p1, &n_a); + if (!PL_sortcop) { + if (priv & OPpSORT_NUMERIC) { + if (priv & OPpSORT_INTEGER) { + if (!SvIOK(*p1)) { + if (SvAMAGIC(*p1)) + overloading = 1; + else + (void)sv_2iv(*p1); + } + } + else { + if (!SvNOK(*p1)) { + if (SvAMAGIC(*p1)) + overloading = 1; + else + (void)sv_2nv(*p1); + } + } + } + else { + if (!SvPOK(*p1)) { + STRLEN n_a; + if (SvAMAGIC(*p1)) + overloading = 1; + else + (void)sv_2pv(*p1, &n_a); + } + } } p1++; } |