Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Disallow @*INC entries to be list of CUR's
As discussed with FROGGS a few weeks ago already.  BTW, this appears to have a
great effect on startup time, judging from CPU usage in spectest.
  • Loading branch information
lizmat committed Aug 1, 2014
1 parent 085ab95 commit b8e660f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
22 changes: 10 additions & 12 deletions src/core/CompUnitRepo.pm
Expand Up @@ -6,27 +6,25 @@ class CompUnitRepo {
my $lock := Lock.new;

method files($file, :$name, :$auth, :$ver) {
for @*INC -> $group {
my @candi;
for $group.list {
if $_ ~~ Str ?? CompUnitRepo::Local::File.new($_) !! $_ -> $cur {
@candi := (@candi, $cur.files($name, :$file, :$auth, :$ver)).flat
for @*INC {
if $_ ~~ Str ?? CompUnitRepo::Local::File.new($_) !! $_ -> $cur {
if $cur.files($name, :$file,:$auth,:$ver).list -> @candi {
return @candi;
}
}
return @candi.sort: { ($^b<ver> // Version.new('0')) cmp ($^a<ver> // Version.new('0')) } if +@candi
}
();
}

method candidates($name, :$file, :$auth, :$ver) {
for @*INC -> $group {
my @candi;
for $group.list {
if $_ ~~ Str ?? CompUnitRepo::Local::File.new($_) !! $_ -> $cur {
@candi := (@candi, $cur.candidates($name, :$file, :$auth, :$ver)).flat
for @*INC {
if $_ ~~ Str ?? CompUnitRepo::Local::File.new($_) !! $_ -> $cur {
if $cur.candidates($name, :$file,:$auth,:$ver).list -> @candi {
return @candi;
}
}
return @candi.sort: { ($^b<ver> // Version.new('0')) cmp ($^a<ver> // Version.new('0')) } if +@candi
}
();
}

method p6ml { $p6ml }
Expand Down
16 changes: 6 additions & 10 deletions src/core/Inc.pm
Expand Up @@ -76,13 +76,12 @@
my $config = "$prefix/share/libraries.json".IO.e ?? from-json( slurp "$prefix/share/libraries.json" ) !! [];

for $config.list -> @group {
my @cur_group;
for @group>>.kv -> $class, $props {
for $props.list -> $prop {
if $prop ~~ Associative {
for $prop.value.flat -> $path {
if make-cur($class, $path) -> $cur {
@cur_group.push: $cur;
@INC.push: $cur;
%CUSTOM_LIB{$prop.key} = $cur;
}
else {
Expand All @@ -93,28 +92,26 @@
else {
for $prop.flat -> $path {
if make-cur($class, $path) -> $cur {
@cur_group.push: $cur;
@INC.push: $cur;
}
}
}
}
}
@INC.push: +@cur_group > 1 ?? [@cur_group] !! @cur_group
}
}
# There is no config file, so pick sane defaults.
else {
# XXX Various issues with this stuff on JVM
my Mu $compiler := nqp::getcurhllsym('$COMPILER_CONFIG'); # TEMPORARY
my @cur_inst;
try {
my $home := %*ENV<HOME> // %*ENV<HOMEDRIVE> ~ %*ENV<HOMEPATH>;
my $ver := nqp::p6box_s(nqp::atkey($compiler, 'version'));
if CompUnitRepo::Local::File.new("$home/.perl6/$ver/lib") -> $cur {
@INC.push: $cur;
}
if CompUnitRepo::Local::Installation.new("$home/.perl6/$ver") -> $cur {
@cur_inst.push: %CUSTOM_LIB<home> = $cur;
@INC.push: %CUSTOM_LIB<home> = $cur;
}
else {
%CUSTOM_LIB<home> = "$home/.perl6/$ver"; # prime it
Expand All @@ -130,24 +127,23 @@
@INC.push: $cur;
}
if CompUnitRepo::Local::Installation.new($prefix) -> $cur {
@cur_inst.push: %CUSTOM_LIB<perl> = $cur;
@INC.push: %CUSTOM_LIB<perl> = $cur;
}
else {
%CUSTOM_LIB<perl> = $prefix; # prime it
}
if CompUnitRepo::Local::Installation.new("$prefix/vendor") -> $cur {
@cur_inst.push: %CUSTOM_LIB<vendor> = $cur;
@INC.push: %CUSTOM_LIB<vendor> = $cur;
}
else {
%CUSTOM_LIB<vendor> = "$prefix/vendor"; # prime it
}
if CompUnitRepo::Local::Installation.new("$prefix/site") -> $cur {
@cur_inst.push: %CUSTOM_LIB<site> = $cur;
@INC.push: %CUSTOM_LIB<site> = $cur;
}
else {
%CUSTOM_LIB<site> = "$prefix/site"; # prime it
}
@INC.push([@cur_inst]) if @cur_inst;
}

PROCESS::<@INC> := @INC;
Expand Down

0 comments on commit b8e660f

Please sign in to comment.