Skip to content

Commit

Permalink
Don't use .perl in serialization ID creation
Browse files Browse the repository at this point in the history
The source-line of 'use' statements is part of .perl output of
CompUnit::DependencySpecification, which was used to create serialization
ID's stored in .precomp files.  This adds a "serialization-id" method that
creates a shorter, but still readable string that is actually valid Raku
code, but does not contain the source-line number.  This should, possibly
drastically, reduce the number of attempts to load the same module.
  • Loading branch information
lizmat committed Jan 2, 2020
1 parent 8a0742e commit bda8dcb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/core.c/CompUnit/DependencySpecification.pm6
Expand Up @@ -12,6 +12,22 @@ class CompUnit::DependencySpecification {
($.auth-matcher //True) ~~ Bool ?? '' !! ":auth<$.auth-matcher>",
($.api-matcher //True) ~~ Bool ?? '' !! ":api<$.api-matcher>";
}

# Provide an human readable *unique* serialization string that does *not*
# contain the line number in the source where it is invoked.
method serialize-id() {
my str $str = self.^name
~ '.new(:short-name<'
~ $.short-name
~ '> :from<'
~ $.from
~ '>';
$str = $str ~ ' :!version-matcher' unless $.version-matcher;
$str = $str ~ ' :!auth-matcher' unless $.auth-matcher;
$str = $str ~ ' :!api-matcher' unless $.api-matcher;

$str ~ ')'
}
}

# vim: ft=perl6 expandtab sw=4
2 changes: 1 addition & 1 deletion src/core.c/CompUnit/PrecompilationUnit.pm6
Expand Up @@ -126,7 +126,7 @@ class CompUnit::PrecompilationDependency::File does CompUnit::PrecompilationDepe
"$.id\0$.src\0$.checksum\0$specs"
#?endif
#?if !jvm
"$.id\0$.src\0$.checksum\0{$!serialized-spec ?? $!serialized-spec !! $!spec.perl}"
"$.id\0$.src\0$.checksum\0{$!serialized-spec ?? $!serialized-spec !! $!spec.serialize-id}"
#?endif
}

Expand Down

0 comments on commit bda8dcb

Please sign in to comment.