Skip to content

SubstituteAndReturn: Faster search for contextual s///r, y///r#2

Merged
zmughal merged 3 commits into
masterfrom
s-and-r-optim
Nov 12, 2022
Merged

SubstituteAndReturn: Faster search for contextual s///r, y///r#2
zmughal merged 3 commits into
masterfrom
s-and-r-optim

Conversation

@zmughal
Copy link
Copy Markdown
Owner

@zmughal zmughal commented Nov 12, 2022

  • Faster search for contextual s///r, y///r
  • SubstituteAndReturn: Check beginning of expression text to find positions
  • SubstituteAndReturn: use array instead of hash for positions

Performance

Before

t/plugin-substituteandreturn.t .. ok    17590 ms ( 0.00 usr  0.00 sys + 17.53 cusr  0.05 csys = 17.58 CPU)

All tests successful.
Files=1, Tests=8, 18 wallclock secs ( 0.01 usr  0.00 sys + 17.53 cusr  0.05 csys = 17.59 CPU)
Result: PASS

After

t/plugin-substituteandreturn.t .. ok     2016 ms ( 0.00 usr  0.00 sys +  1.98 cusr  0.03 csys =  2.01 CPU)

All tests successful.
Files=1, Tests=8,  2 wallclock secs ( 0.01 usr  0.00 sys +  1.98 cusr  0.03 csys =  2.02 CPU)
Result: PASS

@zmughal zmughal marked this pull request as draft November 12, 2022 17:02
@zmughal zmughal marked this pull request as ready for review November 12, 2022 17:02
This uses `each_match_of(Expression)` instead of
`each_match_within(Expression)` because `each_match_within()` is only
able to find one instance of a contextual substitution or
transliteration on each pass because the inner matches did not specify
the entire pattern for what an expression can contain.
…ions

This reduces the calls to `match_positions_of()` which helps skip most
expressions which will not have a `s///` or `y///` in them.
The positions should already be sorted.
@zmughal zmughal merged commit c99d6e5 into master Nov 12, 2022
@zmughal zmughal deleted the s-and-r-optim branch November 12, 2022 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant