This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Avoid pointer churn in study_chunk recursion bitmap allocation
authorYves Orton <demerphq@gmail.com>
Sun, 24 Nov 2013 15:24:16 +0000 (16:24 +0100)
committerYves Orton <demerphq@gmail.com>
Sun, 24 Nov 2013 16:57:49 +0000 (17:57 +0100)
commit09a658380cac4441d8d6c85dc27e49879bf5af26
tree80daf857f81e4bc1c062e924e9fd784fed9586f2
parent1d330354a1a1ceca70309508edd42abe0d141adc
Avoid pointer churn in study_chunk recursion bitmap allocation

Since we can only recurse into a given paren (or the entire pattern)
once, we know that the maximum recursion depth is the number of parens
in the pattern (plus one for "whole pattern"). This means we can
preallocate one large bitmap, and then use different chunks of it
for each level. That avoids SAVEFREEPV costs for each bitmap, which
are likely short anyway. (One could imagine an optimization where a
flag somewhere lets us use the RExC_study_chunk_recursed pointer
as a bitmap, so we dont have to allocate all when we have less than
32 parens.)

This removes the "recursed" argument from study_chunk() and replaces
it with a "recursive_depth" argument which counts how deep we
are in the bitmap "stack".
embed.fnc
proto.h
regcomp.c
regcomp.h