Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use starts|ends-with / substr-eq-at in core
  • Loading branch information
lizmat committed Apr 8, 2015
1 parent eb05181 commit d6b1447
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
6 changes: 2 additions & 4 deletions src/core/Backtrace.pm
Expand Up @@ -25,9 +25,7 @@ my class Backtrace::Frame {

method is-hidden(Backtrace::Frame:D:) { $!code.?is-hidden-from-backtrace }
method is-routine(Backtrace::Frame:D:) { nqp::istype($!code,Routine) }
method is-setting(Backtrace::Frame:D:) {
$!file.chars > 12 && substr($!file,*-12) eq 'CORE.setting'
}
method is-setting(Backtrace::Frame:D:) { $!file.ends-with("CORE.setting") }
}

my class Backtrace is List {
Expand Down Expand Up @@ -71,7 +69,7 @@ my class Backtrace is List {
$file eq 'gen/moar/stage2/NQPHLL.nqp' ||
$file eq 'gen\\moar\\stage2\\NQPHLL.nqp';
my $subname = nqp::p6box_s(nqp::getcodename($sub));
$subname = '<anon>' if substr($subname,0, 6) eq '_block';
$subname = '<anon>' if $subname.starts-with("_block");
last if $subname eq 'handle-begin-time-exceptions';
$new.push: Backtrace::Frame.new(
:line($line.Int),
Expand Down
6 changes: 3 additions & 3 deletions src/core/IO.pm
Expand Up @@ -16,11 +16,11 @@ sub MAKE-ABSOLUTE-PATH($path,$abspath) {
if $path.ord == 47 { # 4x faster substr($path,0,1) eq "/"
return $path;
}
elsif substr($path,1,1) eq ':' { # assume C: something
if substr($path,2,1) eq "/" { # assume C:/ like prefix
elsif $path.substr-eq-at(":",1) { # assume C: something
if $path.substr-eq-at("/",2) { # assume C:/ like prefix
return $path;
}
elsif substr($abspath,0,2) ne substr($path,0,2) {
elsif !$abspath.starts-with(substr($path,0,2)) {
die "Can not set relative dir from different roots";
}
else {
Expand Down
6 changes: 3 additions & 3 deletions src/core/PseudoStash.pm
Expand Up @@ -153,7 +153,7 @@ my class PseudoStash is EnumMap {
}
$res;
}
elsif nqp::bitand_i($!mode, nqp::bitor_i(DYNAMIC_CHAIN, PICK_CHAIN_BY_NAME)) && substr($key, 1, 1) eq '*' {
elsif nqp::bitand_i($!mode, nqp::bitor_i(DYNAMIC_CHAIN, PICK_CHAIN_BY_NAME)) && $key.substr-eq-at("*",1) {
my $found := nqp::getlexreldyn(
nqp::getattr(self, PseudoStash, '$!ctx'),
$nkey);
Expand All @@ -175,7 +175,7 @@ my class PseudoStash is EnumMap {
my Mu $store := nqp::getattr(self, EnumMap, '$!storage');
nqp::bindkey($store, nqp::unbox_s($key), value)
}
elsif nqp::bitand_i($!mode, nqp::bitor_i(DYNAMIC_CHAIN, PICK_CHAIN_BY_NAME)) && substr($key, 1, 1) eq '*' {
elsif nqp::bitand_i($!mode, nqp::bitor_i(DYNAMIC_CHAIN, PICK_CHAIN_BY_NAME)) && $key.substr-eq-at("*",1) {
die "Binding to dynamic variables not yet implemented";
}
else { # STATIC_CHAIN
Expand All @@ -192,7 +192,7 @@ my class PseudoStash is EnumMap {
nqp::getattr(self, EnumMap, '$!storage'),
nqp::unbox_s($key)))
}
elsif nqp::bitand_i($!mode, nqp::bitor_i(DYNAMIC_CHAIN, PICK_CHAIN_BY_NAME)) && substr($key, 1, 1) eq '*' {
elsif nqp::bitand_i($!mode, nqp::bitor_i(DYNAMIC_CHAIN, PICK_CHAIN_BY_NAME)) && $key.substr-eq-at("*",1) {
nqp::isnull(
nqp::getlexreldyn(
nqp::getattr(self, PseudoStash, '$!ctx'),
Expand Down
2 changes: 1 addition & 1 deletion src/core/Version.pm
Expand Up @@ -10,7 +10,7 @@ class Version {
}
self.bless(
:parts(@parts),
:plus(?$s.chars && substr($s,*-1) eq '+'),
:plus($s.ends-with("+")),
);
};

Expand Down

0 comments on commit d6b1447

Please sign in to comment.