diff options
author | David Mitchell <davem@iabyn.com> | 2013-05-31 15:40:48 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2013-06-02 22:28:54 +0100 |
commit | 2ac8ff4bf339d781f96fdfabd34d199a7f9569da (patch) | |
tree | b3e85c2a06111db3d204bb623c99317985977873 /perl.c | |
parent | 331b2dcc3fd1fd971f7a6ed1192c36ceaa0d6a88 (diff) | |
download | perl-2ac8ff4bf339d781f96fdfabd34d199a7f9569da.tar.gz |
eliminate PL_reg_poscache, PL_reg_poscache_size
Eliminate these two global vars (well, fields in the global
PL_reg_state), that hold the regex super-liner cache.
PL_reg_poscache_size gets replaced with a field in the local regmatch_info
struct, while PL_reg_poscache (which needs freeing at end of pattern
execution or on croak()), goes in the regmatch_info_aux struct.
Note that this includes a slight change in behaviour.
Each regex execution now has its own private poscache pointer, initially
null. If the super-linear behaviour is detected, the cache is malloced,
used for the duration of the pattern match, then freed.
The former behaviour allocated a global poscache on first use, which was
retained between regex executions. Since the poscache could between 0.25
and 2x the size of the string being matched, that could potentially be a
big buffer lying around unused. So we save memory at the expense of a new
malloc/free for every regex that triggers super-linear behaviour.
The old behaviour saved the old pointer on reentrancy, then restored the
old one (and possibly freed the new buffer) at exit. Except it didn't for
(?{}), so /(?{ m{something-that-triggers-super-linear-cache} })/ would
leak each time the inner regex was called. This is now fixed
automatically.
Diffstat (limited to 'perl.c')
-rw-r--r-- | perl.c | 2 |
1 files changed, 0 insertions, 2 deletions
@@ -1219,7 +1219,6 @@ perl_destruct(pTHXx) Safefree(PL_origfilename); PL_origfilename = NULL; Safefree(PL_reg_curpm); - Safefree(PL_reg_poscache); free_tied_hv_pool(); Safefree(PL_op_mask); Safefree(PL_psig_name); @@ -3626,7 +3625,6 @@ S_init_interp(pTHX) /* As these are inside a structure, PERLVARI isn't capable of initialising them */ PL_reg_curpm = NULL; - PL_reg_poscache = PL_reg_starttry = NULL; } STATIC void |