Created
January 3, 2015 21:01
-
-
Save usev6/3c5d27e558160c152358 to your computer and use it in GitHub Desktop.
make 'my %h; %h<a>=1; say %h<a>:p(0)' work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/core/Any.pm b/src/core/Any.pm | |
index 6c4a831..a0086ed 100644 | |
--- a/src/core/Any.pm | |
+++ b/src/core/Any.pm | |
@@ -794,10 +794,14 @@ sub SLICE_ONE ( \SELF, $one, $array, *%adv ) is hidden_from_backtrace { | |
elsif %a.exists_key('p') { # :!delete?:p(0|1):* | |
my $p := %a.delete_key('p'); | |
if !%a { # :!delete?:p(0|1) | |
- !$p | $ex(SELF,$one) | |
- ?? RWPAIR($one, | |
- $array ?? SELF.at_pos($one) !! SELF.at_key($one)) | |
- !! (); | |
+ if $ex(SELF,$one) { | |
+ $p ?? RWPAIR($one, | |
+ $array ?? SELF.at_pos($one) !! SELF.at_key($one)) | |
+ !! ($array ?? SELF.at_pos($one) !! SELF.at_key($one)); | |
+ } | |
+ else { | |
+ (); | |
+ } | |
} | |
else { | |
@nogo = <p>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
But on a related note (lizmat mentioned the ternaries): If I modify the original code it seems to run faster:
A naive timing for 4 different cases with current Rakudo:
The same commands with mentioned changes: