Skip to content

Instantly share code, notes, and snippets.

@MasterDuke17
Created August 25, 2023 23:48
Show Gist options
  • Save MasterDuke17/bb2dcbd10d0d4d9af1efbacc4762990a to your computer and use it in GitHub Desktop.
Save MasterDuke17/bb2dcbd10d0d4d9af1efbacc4762990a to your computer and use it in GitHub Desktop.
diff --git src/core.c/Rakudo/Iterator.pm6 src/core.c/Rakudo/Iterator.pm6
index b3efa43d7..928b69467 100644
--- src/core.c/Rakudo/Iterator.pm6
+++ src/core.c/Rakudo/Iterator.pm6
@@ -828,14 +828,14 @@ method new(\n,\k,\b)
method pull-one() {
my int $n = $!n; # lexicals faster
my int $k = $!k;
- my int $running = 1;
my $combination := $!combination;
my $stack := $!stack;
+ my int $index = -1,
nqp::while(
- ($running && (my int $elems = nqp::elems($stack))),
+ (nqp::isne_i($index,$k) && (my int $elems = nqp::elems($stack))),
nqp::stmts(
- (my int $index = $elems - 1),
+ ($index = $elems - 1),
(my int $value = nqp::pop_i($stack)),
nqp::while(
nqp::islt_i($value,$n) && nqp::islt_i($index,$k),
@@ -846,7 +846,6 @@ method pull-one()
nqp::push_i($stack,$value)
)
),
- ($running = nqp::isne_i($index,$k)),
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment