Skip to content

Instantly share code, notes, and snippets.

@lizmat
Created October 19, 2020 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizmat/2b0975d71d5f7f10e4b124a10bae452f to your computer and use it in GitHub Desktop.
Save lizmat/2b0975d71d5f7f10e4b124a10bae452f to your computer and use it in GitHub Desktop.
making Seq.elems **not** cache
$ git diff
diff --git a/src/core.c/Seq.pm6 b/src/core.c/Seq.pm6
index edf58b6d6..93ac5504c 100644
--- a/src/core.c/Seq.pm6
+++ b/src/core.c/Seq.pm6
@@ -48,6 +48,18 @@ my class Seq is Cool does Iterable does Sequence {
self.List.Capture
}
+ method !count(--> Int:D) {
+ my int $count;
+ my $iter := $!iter;
+
+ nqp::until(
+ nqp::eqaddr($iter.pull-one,IterationEnd),
+ ++$count
+ );
+
+ $count
+ }
+
method elems() {
nqp::if(
self.is-lazy,
@@ -55,7 +67,7 @@ my class Seq is Cool does Iterable does Sequence {
nqp::if(
nqp::isconcrete($!iter) && nqp::istype($!iter,PredictiveIterator),
$!iter.count-only,
- self.cache.elems
+ self!count
)
)
}
Test Summary Report
-------------------
t/spec/S02-types/capture.t (Wstat: 65280 Tests: 32 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 46 tests but ran 32.
t/spec/S02-types/pair.rakudo.moar (Wstat: 65280 Tests: 177 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 182 tests but ran 177.
t/spec/S02-types/subset-6c.t (Wstat: 256 Tests: 51 Failed: 1)
Failed test: 13
Non-zero exit status: 1
t/spec/S03-binding/hashes.t (Wstat: 256 Tests: 39 Failed: 1)
Failed test: 38
Non-zero exit status: 1
t/spec/S02-types/subset-6e.t (Wstat: 256 Tests: 60 Failed: 1)
Failed test: 14
Non-zero exit status: 1
t/spec/S03-sequence/arity-2-or-more.t (Wstat: 1024 Tes Failed test: 9
Non-zero exit status: 1
Parse errors: Bad plan. You planned 178 tests but ran 9.
t/spec/S16-io/words.t (Wstat: 65280 Tests: 0 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 11 tests but ran 0.
t/spec/S32-array/adverbs.t (Wstat: 15360 Tests: 606 Failed: 60)
Failed tests: 20, 22, 40, 42, 60, 62, 80, 82, 100, 102
120, 122, 140, 142, 160, 162, 180, 182
200, 202, 220, 222, 240, 242, 260, 262
280, 282, 300, 302, 320, 322, 340, 342
360, 362, 380, 382, 400, 402, 420, 422
440, 442, 460, 462, 480, 482, 500, 502
520, 522, 540, 542, 560, 562, 580, 582
600, 602
Non-zero exit status: 60
t/spec/S32-hash/slice.rakudo.moar (Wstat: 0 Tests: 31 Failed: 0)
TODO passed: 15-22, 25-26
t/spec/S32-hash/adverbs.t (Wstat: 28672 Tests: 1128 Failed: 112)
Failed tests: 22, 24, 42, 44, 62, 64, 82, 84, 102, 104
122, 124, 142, 144, 162, 164, 182, 184
202, 204, 222, 224, 242, 244, 262, 264
283-284, 302, 304, 322, 324, 342, 344, 362
364, 382, 384, 402, 404, 422, 424, 442
444, 462, 464, 482, 484, 502, 504, 522
524, 542, 544, 563-564, 582, 584, 602, 604
622, 624, 642, 644, 662, 664, 682, 684
702, 704, 722, 724, 742, 744, 762, 764
782, 784, 802, 804, 822, 824, 843-844, 862
864, 882, 884, 902, 904, 922, 924, 942
944, 962, 964, 982, 984, 1002, 1004, 1022
1024, 1042, 1044, 1062, 1064, 1082, 1084
1102, 1104, 1123-1124
Non-zero exit status: 112
t/spec/S32-exceptions/misc2.rakudo.moar (Wstat: 256 Tests: 269 Failed: 1)
Failed test: 47
Non-zero exit status: 1
t/spec/S32-list/skip.t (Wstat: 256 Tests: 27 Failed: 1)
Failed test: 25
Non-zero exit status: 1
t/spec/S32-num/cool-num.rakudo.moar (Wstat: 256 Tests: 46 Failed: 1)
Failed test: 46
Non-zero exit status: 1
t/spec/S32-str/split.rakudo.moar (Wstat: 256 Tests: 65 Failed: 1)
Failed test: 57
Non-zero exit status: 1
t/spec/S15-normalization/nfc-concat.t (Wstat: 65024 Tests: 1919 Failed: 1919)
Failed tests: 1-1919
Non-zero exit status: 254
t/spec/integration/advent2012-day14.t (Wstat: 15 Tests: 3 Failed: 0)
Non-zero wait status: 15
Parse errors: Bad plan. You planned 6 tests but ran 3.
Files=1336, Tests=113510, 282 wallclock secs (38.20 usr 10.52 sys + 3522.86 cusr 355.16 csys = 3926.74 CPU)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment