develooper Front page | perl.perl5.porters | Postings from September 2012

[perl #114410] Substr giving wrong results on $1 with utf8

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
September 8, 2012 22:31
Subject:
[perl #114410] Substr giving wrong results on $1 with utf8
Message ID:
rt-3.6.HEAD-11172-1347168699-1045.114410-15-0@perl.org
On Thu Sep 06 06:06:51 2012, nicholas wrote:
> On Fri, Aug 31, 2012 at 08:29:48AM -0700, Father Chrysostomos via RT
wrote:
> 
> > I'm also wondering whether it's even worth creating the utf8 cache to
> > begin with on magical values, as it will be invalidated almost
> > immediately.  It seems that the extra work to facilitate an optimisation
> > actually slows things down.
> 
> I'm not sure if any code relies for performance on being able to call it
> twice on the same string. I thought that pp_substr() did, but actually
> that's taking advantage of the fact that the call takes two positions to
> convert.
> 
> pp_index() calls sv_pos_u2b() and sv_pos_b2c() on the same SV.
> I'm not sure whether (a) that matters (b) whether they can be
condensed into
> one call.
> 
> If no op or clearly related code path ends up calling more than one
function
> twice, then it seems to make most sense to avoid actually storing the
cache
> structure on the SV for "active" values (magic and overloading - I think
> that's all of them).

Even if it does call it twice, doing so on overloading is still
incorrect, as it will call overloading twice.

So I think what I suggested is the correct fix.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=114410

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About