Skip to content

Commit

Permalink
Make internal encoding sanity lookup about 6x as fast
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Oct 24, 2018
1 parent 54483d1 commit 64693a2
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/core/Rakudo/Internals.pm6
Expand Up @@ -314,16 +314,13 @@ my class Rakudo::Internals {
'windows932', 'windows-932',
);
method NORMALIZE_ENCODING(Str:D \encoding) {
my str $key = nqp::unbox_s(encoding);
if nqp::existskey($encodings,$key) {
nqp::atkey($encodings,$key)
}
else {
my str $lc = nqp::lc($key);
nqp::existskey($encodings,$lc)
?? nqp::atkey($encodings,$lc)
!! nqp::lc($key)
}
nqp::ifnull(
nqp::atkey($encodings,encoding),
nqp::ifnull(
nqp::atkey($encodings,nqp::lc(encoding)),
nqp::lc(encoding)
)
)
}

# 1 if all elements of given type, otherwise 0
Expand Down

0 comments on commit 64693a2

Please sign in to comment.