printf "%s: %.0f ms.\n", $msg, 1e3 * $elapsed;
}
+# Unicode::Collate is seemingly slow, so add a cache for each name part
+# (which, of course, only works for equality).
+# Doesn't seem to help the initial one, though; I guess not enough people
+# have the same names.
+my %sort_key_cache = ();
+my $sort_key_sp = $uca->getSortKey(' ');
+
sub sort_key {
my $m = shift;
- return $uca->getSortKey($m);
+ my $sk;
+ for my $part (split /\s+/, $m) {
+ my $psk = \$sort_key_cache{$part};
+ if (!defined($$psk)) {
+ $$psk = $uca->getSortKey($part);
+ }
+ if (defined($sk)) {
+ $sk .= $sort_key_sp;
+ $sk .= $$psk;
+ } else {
+ $sk = $$psk;
+ }
+ }
+ return $sk;
}
sub get_oauth_bearer_token {