Skip to content

Commit

Permalink
Fast-track .DELETE-POS for 1,2,3dimmed arrays
Browse files Browse the repository at this point in the history
Makes them about 20x faster than using generic N-dimmed DELETE-POS
  • Loading branch information
lizmat committed Nov 4, 2016
1 parent 6ccecb1 commit 55b9e90
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/core/Shaped1Array.pm
Expand Up @@ -69,6 +69,35 @@
)
}

multi method DELETE-POS(::?CLASS:D: int \one) is raw {
nqp::if(
nqp::isnull(my $value := nqp::atpos(
nqp::getattr(self,List,'$!reified'),
one)),
Nil,
nqp::stmts(
nqp::bindpos(
nqp::getattr(self,List,'$!reified'),
one, nqp::null),
$value
)
)
}
multi method DELETE-POS(::?CLASS:D: Int:D \one) is raw {
nqp::if(
nqp::isnull(my $value := nqp::atpos(
nqp::getattr(self,List,'$!reified'),
one)),
Nil,
nqp::stmts(
nqp::bindpos(
nqp::getattr(self,List,'$!reified'),
one, nqp::null),
$value
)
)
}

multi method STORE(::?CLASS:D: Iterable:D \in) {
nqp::stmts(
(my \list := nqp::getattr(self,List,'$!reified')),
Expand Down
29 changes: 29 additions & 0 deletions src/core/Shaped2Array.pm
Expand Up @@ -82,6 +82,35 @@
)
)
}

multi method DELETE-POS(::?CLASS:D: int \one, int \two) is raw {
nqp::if(
nqp::isnull(my $value := nqp::atpos2d(
nqp::getattr(self,List,'$!reified'),
one, two)),
Nil,
nqp::stmts(
nqp::bindpos2d(
nqp::getattr(self,List,'$!reified'),
one, two, nqp::null),
$value
)
)
}
multi method DELETE-POS(::?CLASS:D: Int:D \one, Int:D \two) is raw {
nqp::if(
nqp::isnull(my $value := nqp::atpos2d(
nqp::getattr(self,List,'$!reified'),
one, two)),
Nil,
nqp::stmts(
nqp::bindpos2d(
nqp::getattr(self,List,'$!reified'),
one, two, nqp::null),
$value
)
)
}
}

# vim: ft=perl6 expandtab sw=4
29 changes: 29 additions & 0 deletions src/core/Shaped3Array.pm
Expand Up @@ -83,6 +83,35 @@
)
)
}

multi method DELETE-POS(::?CLASS:D: int \one, int \two, int \three) is raw {
nqp::if(
nqp::isnull(my $value := nqp::atpos3d(
nqp::getattr(self,List,'$!reified'),
one, two, three)),
Nil,
nqp::stmts(
nqp::bindpos3d(
nqp::getattr(self,List,'$!reified'),
one, two, three, nqp::null),
$value
)
)
}
multi method DELETE-POS(::?CLASS:D: Int:D \one, Int:D \two, Int:D \three) is raw {
nqp::if(
nqp::isnull(my $value := nqp::atpos3d(
nqp::getattr(self,List,'$!reified'),
one, two, three)),
Nil,
nqp::stmts(
nqp::bindpos3d(
nqp::getattr(self,List,'$!reified'),
one, two, three, nqp::null),
$value
)
)
}
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit 55b9e90

Please sign in to comment.