Skip to content

Commit

Permalink
utf8.c: Shorten hash key for speed
Browse files Browse the repository at this point in the history
Experiments have shown that longer hash keys impact performance.  See
the thread at
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2012-08/msg00869.html

This patch shortens a key used very frequently.  There are other keys in
this hash which are used frequently in some circumstances, but I expect
to change to use fewer in the future, so am not changing them now
  • Loading branch information
Karl Williamson committed Aug 26, 2012
1 parent 5d3d13d commit 5c9f4bd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions utf8.c
Expand Up @@ -3067,7 +3067,7 @@ Perl__core_swash_init(pTHX_ const char* pkg, const char* name, SV *listsv, I32 m
* inversion list, or create one for it */

if (swash_hv) {
swash_invlistsvp = hv_fetchs(swash_hv, "I", FALSE);
swash_invlistsvp = hv_fetchs(swash_hv, "V", FALSE);
if (swash_invlistsvp) {
swash_invlist = *swash_invlistsvp;
invlist_in_swash_is_valid = TRUE;
Expand Down Expand Up @@ -3103,7 +3103,7 @@ Perl__core_swash_init(pTHX_ const char* pkg, const char* name, SV *listsv, I32 m
* be that there was an inversion list in the swash which didn't get
* touched; otherwise save the one computed one */
if (! invlist_in_swash_is_valid) {
if (! hv_stores(MUTABLE_HV(SvRV(retval)), "INVLIST", swash_invlist))
if (! hv_stores(MUTABLE_HV(SvRV(retval)), "V", swash_invlist))
{
Perl_croak(aTHX_ "panic: hv_store() unexpectedly failed");
}
Expand Down Expand Up @@ -3405,7 +3405,7 @@ S_swatch_get(pTHX_ SV* swash, UV start, UV span)
U8 *l, *lend, *x, *xend, *s, *send;
STRLEN lcur, xcur, scur;
HV *const hv = MUTABLE_HV(SvRV(swash));
SV** const invlistsvp = hv_fetchs(hv, "INVLIST", FALSE);
SV** const invlistsvp = hv_fetchs(hv, "V", FALSE);

SV** listsvp = NULL; /* The string containing the main body of the table */
SV** extssvp = NULL;
Expand Down Expand Up @@ -4150,7 +4150,7 @@ Perl__get_swash_invlist(pTHX_ SV* const swash)
return NULL;
}

ptr = hv_fetchs(MUTABLE_HV(SvRV(swash)), "INVLIST", FALSE);
ptr = hv_fetchs(MUTABLE_HV(SvRV(swash)), "V", FALSE);

if (! ptr) {
return NULL;
Expand Down

0 comments on commit 5c9f4bd

Please sign in to comment.