<commit_before>my class NFC is repr('VMArray') is array_type(uint32) { ... }
my class NFD is repr('VMArray') is array_type(uint32) { ... }
my class NFKC is repr('VMArray') is array_type(uint32) { ... }
my class NFKD is repr('VMArray') is array_type(uint32) { ... }

my class Uni does Positional[uint32] does Stringy is repr('VMArray') is array_type(uint32) {
    method new(*@codes) {
        my $uni := nqp::create(self);
        my int $n = @codes.elems;
        loop (my int $i = 0; $i < $n; $i = $i + 1) {
            nqp::bindpos_i($uni, $i, @codes.AT-POS($i));
        }
        $uni
    }

    my class UniList does PredictiveIterator {
        has $!uni;
        has int $!els;
        has int $!i;
        method !SET-SELF(\uni) {
            $!uni := uni;
            $!i    = -1;
            $!els  = nqp::elems(uni);
            self
        }
        method new (\uni) { nqp::create(self)!SET-SELF: uni }
        method pull-one {
            nqp::if(
              nqp::islt_i(($!i = nqp::add_i($!i, 1)), $!els),
              nqp::atpos_i($!uni, $!i),
              IterationEnd)
        }
        method push-all($target --> IterationEnd) {
            nqp::stmts(
              (my     $uni := $!uni), # lexicals faster than attrs
              (my int $els  = $!els),
              (my int $i    = $!i),
              nqp::while(
                nqp::islt_i(($i = nqp::add_i($i, 1)), $els),
                $target.push: nqp::atpos_i($uni, $i)),
              ($!i = $i))
        }
        method count-only {
            nqp::p6box_i(
              nqp::if(
                nqp::islt_i($!i, nqp::elems($!uni)),
                nqp::sub_i(nqp::elems($!uni), nqp::add_i($!i, 1)),
                0))
        }
    }
    method list(Uni:D:) { Seq.new(UniList.new(self)) }

    method Uni(Uni:D:) {
        self
    }

    method NFC(Uni:D:) {
        nqp::normalizecodes(self, nqp::const::NORMALIZE_NFC, nqp::create(NFC))
    }

    method NFD(Uni:D:) {<commit_msg>Simplify Uni.list.count-only<commit_after>my class NFC is repr('VMArray') is array_type(uint32) { ... }
my class NFD is repr('VMArray') is array_type(uint32) { ... }
my class NFKC is repr('VMArray') is array_type(uint32) { ... }
my class NFKD is repr('VMArray') is array_type(uint32) { ... }

my class Uni does Positional[uint32] does Stringy is repr('VMArray') is array_type(uint32) {
    method new(*@codes) {
        my $uni := nqp::create(self);
        my int $n = @codes.elems;
        loop (my int $i = 0; $i < $n; $i = $i + 1) {
            nqp::bindpos_i($uni, $i, @codes.AT-POS($i));
        }
        $uni
    }

    my class UniList does PredictiveIterator {
        has $!uni;
        has int $!els;
        has int $!i;
        method !SET-SELF(\uni) {
            $!uni := uni;
            $!i    = -1;
            $!els  = nqp::elems(uni);
            self
        }
        method new (\uni) { nqp::create(self)!SET-SELF: uni }
        method pull-one {
            nqp::if(
              nqp::islt_i(($!i = nqp::add_i($!i, 1)), $!els),
              nqp::atpos_i($!uni, $!i),
              IterationEnd
            )
        }
        method push-all($target --> IterationEnd) {
            nqp::stmts(
              (my     $uni := $!uni), # lexicals faster than attrs
              (my int $els  = $!els),
              (my int $i    = $!i),
              nqp::while(
                nqp::islt_i(($i = nqp::add_i($i, 1)), $els),
                $target.push: nqp::atpos_i($uni, $i)
              ),
              ($!i = $i)
            )
        }
        method count-only(--> Int:D) {
            nqp::p6box_i($!els - $!i - nqp::islt_i($!i,$!els))
        }
    }
    method list(Uni:D:) { Seq.new(UniList.new(self)) }

    method Uni(Uni:D:) {
        self
    }

    method NFC(Uni:D:) {
        nqp::normalizecodes(self, nqp::const::NORMALIZE_NFC, nqp::create(NFC))
    }

    method NFD(Uni:D:) {
{'fraction_non_alphanumeric': 0.17704330002562133, 'fraction_numerical': 0.009736100435562388, 'mean_word_length': 1.65578231292517, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2080620', 'n_tokens_mistral': 1494, 'n_tokens_neox': 1413, 'n_words': 299}