Skip to content

Commit

Permalink
Cache path to p5helper.so in a state variable
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Sep 26, 2014
1 parent 1d3d369 commit aa27ba0
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/Inline/Perl5.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ use NativeCall;

sub native(Sub $sub) {
my $so = 'p5helper.so';
my Str $path;
for @*INC {
if ($_ ~ "/Inline/$so").IO ~~ :f {
$path = $_ ~ "/Inline/$so";
trait_mod:<is>($sub, :native($path));
return;
state Str $path;
unless $path {
for @*INC {
if "$_/Inline/$so".IO ~~ :f {
$path = "$_/Inline/$so";
last;
}
}
}
die "unable to find $so";
unless $path {
die "unable to find Inline/$so IN \@*INC";
}
trait_mod:<is>($sub, :native($path));
}

class Perl5Object { ... }
Expand Down

0 comments on commit aa27ba0

Please sign in to comment.