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 /scope.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 'scope.c')
-rw-r--r-- | scope.c | 3 |
1 files changed, 0 insertions, 3 deletions
@@ -1233,9 +1233,6 @@ Perl_leave_scope(pTHX_ I32 base) - SAVESTACK_ALLOC_FOR_RE_SAVE_STATE); PL_savestack_ix -= SAVESTACK_ALLOC_FOR_RE_SAVE_STATE; - if (PL_reg_poscache != state->re_state_reg_poscache) { - Safefree(PL_reg_poscache); - } Copy(state, &PL_reg_state, 1, struct re_save_state); } break; |