This should not change the behaviour. It is just unnecessary to cache
positions on a magical string, as we then just have to invalidate the
cache in mg_get. It will be more efficient just not to create the
cache to begin with.
This does not allow us to remove the cache invalidation in mg_get,
because the cache can sometimes be created while magic is being called
and SvMAGICAL is off. It just avoids extra work in those cases that
are detectable.
if (!uoffset)
return 0;
- if (!SvREADONLY(sv)
+ if (!SvREADONLY(sv) && !SvGMAGICAL(sv)
&& PL_utf8cache
&& (*mgp || (SvTYPE(sv) >= SVt_PVMG &&
(*mgp = mg_find(sv, PERL_MAGIC_utf8))))) {
boffset = real_boffset;
}
- if (PL_utf8cache) {
+ if (PL_utf8cache && !SvGMAGICAL(sv)) {
if (at_end)
utf8_mg_len_cache_update(sv, mgp, uoffset);
else