Skip to content

Commit

Permalink
Make sure Set objects are initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
titsuki committed May 31, 2017
1 parent 6ae2a4e commit ac39f2c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Algorithm/AhoCorasick.pm6
Expand Up @@ -45,7 +45,7 @@ method !build-automata() {

method match($text) {
my $all = self.locate($text);
my Set $matched;
my Set $matched = set();
for $all.keys -> $keyword {
$matched = $matched (|) $keyword;
}
Expand Down
4 changes: 4 additions & 0 deletions lib/Algorithm/AhoCorasick/Node.pm6
Expand Up @@ -4,3 +4,7 @@ unit class Algorithm::AhoCorasick::Node;
has Set $.matched-string is rw;
has Algorithm::AhoCorasick::Node %.transitions is rw;
has Algorithm::AhoCorasick::Node $.failure is rw;

submethod TWEAK {
$!matched-string = set();
}

0 comments on commit ac39f2c

Please sign in to comment.