<commit_before>{
    # Set up the skeletons of the IO::Handle objects that can be setup
    # at compile time.  Then, when running the mainline of the setting
    # at startup, plug in the low level handles and set up the encoder
    # and decoders.  This shaves off about 1.5% of bare startup.
    my constant NL-IN    = ["\x0A", "\r\n"];
    my constant NL-OUT   = "\n";
    my constant ENCODING = "utf8";

#?if jvm
    my $in := do {
#?endif
#?if !jvm
    my $in := BEGIN {
#?endif
        my $handle := nqp::p6bindattrinvres(
          nqp::create(IO::Handle),IO::Handle,'$!path',nqp::p6bindattrinvres(
            nqp::create(IO::Special),IO::Special,'$!what','<STDIN>'
          )
        );
        nqp::getattr($handle,IO::Handle,'$!chomp')    = True;
        nqp::getattr($handle,IO::Handle,'$!nl-in')    = NL-IN;
        nqp::getattr($handle,IO::Handle,'$!nl-out')   = NL-OUT;
        nqp::getattr($handle,IO::Handle,'$!encoding') = ENCODING;
        $handle
    }
#?if jvm
    my $out := do {
#?endif
#?if !jvm
    my $out := BEGIN {
#?endif
        my $handle := nqp::p6bindattrinvres(
          nqp::create(IO::Handle),IO::Handle,'$!path',nqp::p6bindattrinvres(
            nqp::create(IO::Special),IO::Special,'$!what','<STDOUT>'
          )
        );
        nqp::getattr($handle,IO::Handle,'$!chomp')    = True;
        nqp::getattr($handle,IO::Handle,'$!nl-in')    = NL-IN;
        nqp::getattr($handle,IO::Handle,'$!nl-out')   = NL-OUT;
        nqp::getattr($handle,IO::Handle,'$!encoding') = ENCODING;
        $handle
    }
#?if jvm
    my $err := do {
#?endif
#?if !jvm
    my $err := BEGIN {
#?endif
        my $handle := nqp::p6bindattrinvres(
          nqp::create(IO::Handle),IO::Handle,'$!path',nqp::p6bindattrinvres(
            nqp::create(IO::Special),IO::Special,'$!what','<STDERR>'
          )
        );
        nqp::getattr($handle,IO::Handle,'$!chomp')    = True;
        nqp::getattr($handle,IO::Handle,'$!nl-in')    = NL-IN;
        nqp::getattr($handle,IO::Handle,'$!nl-out')   = NL-OUT;
        nqp::getattr($handle,IO::Handle,'$!encoding') = ENCODING;
        $handle
    }

    my $encoding := Encoding::Registry.utf8;
    my $encoder  := $encoding.encoder(:translate-nl);
    my $decoder  := $encoding.decoder(:translate-nl);

    sub activate-std(IO::Handle:D $handle, Mu \PIO) {
        nqp::setbuffersizefh(PIO,8192) unless nqp::isttyfh(PIO);
        nqp::bindattr(
          $handle,IO::Handle,'$!decoder',$decoder
        ).set-line-separators(NL-IN);
        nqp::bindattr($handle,IO::Handle,'$!encoder',$encoder);
        nqp::bindattr($handle,IO::Handle,'$!PIO',PIO);
        $handle
    }

    # Activate the standard handle skeletons at runtime
    PROCESS::<$IN>  = activate-std($in,  nqp::getstdin);
    PROCESS::<$OUT> = activate-std($out, nqp::getstdout);
    PROCESS::<$ERR> = activate-std($err, nqp::getstderr);
}

proto sub printf($, |) {*}
multi sub printf(Str(Cool) $format, Junction:D \j) {
    my $out := $*OUT;
    j.THREAD: { $out.print: sprintf $format, |$_ }
}
multi sub printf(Str(Cool) $format, |) {
   my $args := nqp::p6argvmarray;
   nqp::shift($args);
   $*OUT.print: sprintf $format, nqp::hllize($args)
}

proto sub print(|) {*}
multi sub print(--> True) { }    # nothing to do
multi sub print(Junction:D \j) {
    my $out := $*OUT;
    j.THREAD: { $out.print: .Str }
}
multi sub print(Str:D \x) { $*OUT.print(x) }
multi sub print(\x) { $*OUT.print(x.Str) }
multi sub print(|) {
    $*OUT.print:
      nqp::join("",Rakudo::Internals.StrList2list_s(nqp::p6argvmarray))
}

# To ensure that classes that mimic the $*OUT / $*ERR API (which are only<commit_msg>Fix some odd indenting, no functional change<commit_after>{
    # Set up the skeletons of the IO::Handle objects that can be setup
    # at compile time.  Then, when running the mainline of the setting
    # at startup, plug in the low level handles and set up the encoder
    # and decoders.  This shaves off about 1.5% of bare startup.
    my constant NL-IN    = ["\x0A", "\r\n"];
    my constant NL-OUT   = "\n";
    my constant ENCODING = "utf8";

#?if jvm
    my $in := do {
#?endif
#?if !jvm
    my $in := BEGIN {
#?endif
        my $handle := nqp::p6bindattrinvres(
          nqp::create(IO::Handle),IO::Handle,'$!path',nqp::p6bindattrinvres(
            nqp::create(IO::Special),IO::Special,'$!what','<STDIN>'
          )
        );
        nqp::getattr($handle,IO::Handle,'$!chomp')    = True;
        nqp::getattr($handle,IO::Handle,'$!nl-in')    = NL-IN;
        nqp::getattr($handle,IO::Handle,'$!nl-out')   = NL-OUT;
        nqp::getattr($handle,IO::Handle,'$!encoding') = ENCODING;
        $handle
    }
#?if jvm
    my $out := do {
#?endif
#?if !jvm
    my $out := BEGIN {
#?endif
        my $handle := nqp::p6bindattrinvres(
          nqp::create(IO::Handle),IO::Handle,'$!path',nqp::p6bindattrinvres(
            nqp::create(IO::Special),IO::Special,'$!what','<STDOUT>'
          )
        );
        nqp::getattr($handle,IO::Handle,'$!chomp')    = True;
        nqp::getattr($handle,IO::Handle,'$!nl-in')    = NL-IN;
        nqp::getattr($handle,IO::Handle,'$!nl-out')   = NL-OUT;
        nqp::getattr($handle,IO::Handle,'$!encoding') = ENCODING;
        $handle
    }
#?if jvm
    my $err := do {
#?endif
#?if !jvm
    my $err := BEGIN {
#?endif
        my $handle := nqp::p6bindattrinvres(
          nqp::create(IO::Handle),IO::Handle,'$!path',nqp::p6bindattrinvres(
            nqp::create(IO::Special),IO::Special,'$!what','<STDERR>'
          )
        );
        nqp::getattr($handle,IO::Handle,'$!chomp')    = True;
        nqp::getattr($handle,IO::Handle,'$!nl-in')    = NL-IN;
        nqp::getattr($handle,IO::Handle,'$!nl-out')   = NL-OUT;
        nqp::getattr($handle,IO::Handle,'$!encoding') = ENCODING;
        $handle
    }

    my $encoding := Encoding::Registry.utf8;
    my $encoder  := $encoding.encoder(:translate-nl);
    my $decoder  := $encoding.decoder(:translate-nl);

    sub activate-std(IO::Handle:D $handle, Mu \PIO) {
        nqp::setbuffersizefh(PIO,8192) unless nqp::isttyfh(PIO);
        nqp::bindattr(
          $handle,IO::Handle,'$!decoder',$decoder
        ).set-line-separators(NL-IN);
        nqp::bindattr($handle,IO::Handle,'$!encoder',$encoder);
        nqp::bindattr($handle,IO::Handle,'$!PIO',PIO);
        $handle
    }

    # Activate the standard handle skeletons at runtime
    PROCESS::<$IN>  = activate-std($in,  nqp::getstdin);
    PROCESS::<$OUT> = activate-std($out, nqp::getstdout);
    PROCESS::<$ERR> = activate-std($err, nqp::getstderr);
}

proto sub printf($, |) {*}
multi sub printf(Str(Cool) $format, Junction:D \j) {
    my $out := $*OUT;
    j.THREAD: { $out.print: sprintf $format, |$_ }
}
multi sub printf(Str(Cool) $format, |) {
    my $args := nqp::p6argvmarray;
    nqp::shift($args);
    $*OUT.print: sprintf $format, nqp::hllize($args)
}

proto sub print(|) {*}
multi sub print(--> True) { }    # nothing to do
multi sub print(Junction:D \j) {
    my $out := $*OUT;
    j.THREAD: { $out.print: .Str }
}
multi sub print(Str:D \x) { $*OUT.print(x) }
multi sub print(\x) { $*OUT.print(x.Str) }
multi sub print(|) {
    $*OUT.print:
      nqp::join("",Rakudo::Internals.StrList2list_s(nqp::p6argvmarray))
}

# To ensure that classes that mimic the $*OUT / $*ERR API (which are only
{'fraction_non_alphanumeric': 0.19925946242457487, 'fraction_numerical': 0.004936917169500823, 'mean_word_length': 3.0788590604026846, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '3922047', 'n_tokens_mistral': 2727, 'n_tokens_neox': 2698, 'n_words': 509}