diff options
author | Karl Williamson <khw@cpan.org> | 2020-11-07 07:21:52 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2022-06-05 09:17:50 -0600 |
commit | aecef8c416f97e8830a9b63bd14720b1d957a761 (patch) | |
tree | 219216ea636202462ad25ad383234d11005f6a1e /op.c | |
parent | 7008caa915ad99e650acf2aea40612b5e48b7ba2 (diff) | |
download | perl-aecef8c416f97e8830a9b63bd14720b1d957a761.tar.gz |
Make tr/// SV compiled components ReadOnly
This could trigger some optimisations, and makes it clear to maintainers
that they do not get modified.
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -8018,6 +8018,7 @@ S_pmtrans(pTHX_ OP *o, OP *expr, OP *repl) || r_map[len-1] == TR_SPECIAL_HANDLING)))) { SV* r_map_sv; + SV* temp_sv; /* A UTF-8 op is generated, indicated by this flag. This op is an * sv_op */ @@ -8029,19 +8030,26 @@ S_pmtrans(pTHX_ OP *o, OP *expr, OP *repl) /* The inversion map is pushed; first the list. */ invmap = MUTABLE_AV(newAV()); + + SvREADONLY_on(t_invlist); av_push(invmap, t_invlist); /* 2nd is the mapping */ r_map_sv = newSVpvn((char *) r_map, len * sizeof(UV)); + SvREADONLY_on(r_map_sv); av_push(invmap, r_map_sv); /* 3rd is the max possible expansion factor */ - av_push(invmap, newSVnv(max_expansion)); + temp_sv = newSVnv(max_expansion); + SvREADONLY_on(temp_sv); + av_push(invmap, temp_sv); /* Characters that are in the search list, but not in the replacement * list are mapped to the final character in the replacement list */ if (! del && r_count < t_count) { - av_push(invmap, newSVuv(final_map)); + temp_sv = newSVuv(final_map); + SvREADONLY_on(temp_sv); + av_push(invmap, temp_sv); } #ifdef USE_ITHREADS |