Skip to content

Instantly share code, notes, and snippets.

@moritz
Created October 11, 2014 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moritz/b4167b60f7baf97d8330 to your computer and use it in GitHub Desktop.
Save moritz/b4167b60f7baf97d8330 to your computer and use it in GitHub Desktop.
Untested patch to speed up certain transliterations by ~25%
diff --git a/src/core/Str.pm b/src/core/Str.pm
index c0c886a..3590fbe 100644
--- a/src/core/Str.pm
+++ b/src/core/Str.pm
@@ -1081,10 +1081,9 @@ my class Str does Stringy { # declared in BOOTSTRAP
}
multi method triage_substitution($_ where { .key ~~ Cool }) {
- return unless defined index($!source, .key, $!index);
- self.compare_substitution($_,
- index($!source, .key, $!index),
- .key.chars);
+ my $pos := index($!source, .key, $!index);
+ return unless defined $pos;
+ self.compare_substitution($_, $pos, .key.chars);
}
multi method triage_substitution($_) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment