diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-05-13 21:21:49 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-06-11 10:12:19 +0200 |
commit | c7fdacb978df1723dbbd70b5517ff77db208a23e (patch) | |
tree | 4060de2a609f4cf76b76edbc5b8cc86d9c77de7b /mg_vtable.h | |
parent | 406700cc2c30076030b511780fa9f662c8bfec20 (diff) | |
download | perl-c7fdacb978df1723dbbd70b5517ff77db208a23e.tar.gz |
Refactor Perl_get_vtbl() to a small array lookup from a large switch statement.
Provide magic_vtable_max, the number of elements in PL_magic_vtables[].
Diffstat (limited to 'mg_vtable.h')
-rw-r--r-- | mg_vtable.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/mg_vtable.h b/mg_vtable.h index 21f2e7a874..2db8f3fe8c 100644 --- a/mg_vtable.h +++ b/mg_vtable.h @@ -38,7 +38,8 @@ enum { /* pass one of these to get_vtbl */ want_vtbl_utf8, want_vtbl_collxfrm, want_vtbl_hintselem, - want_vtbl_hints + want_vtbl_hints, + magic_vtable_max }; /* These all need to be 0, not NULL, as NULL can be (void*)0, which is a @@ -59,7 +60,7 @@ enum { /* pass one of these to get_vtbl */ */ #ifdef DOINIT -EXT_MGVTBL PL_magic_vtables[] = { +EXT_MGVTBL PL_magic_vtables[magic_vtable_max] = { { Perl_magic_get, Perl_magic_set, Perl_magic_len, 0, 0, 0, 0, 0 }, { 0, Perl_magic_set_all_env, 0, Perl_magic_clear_all_env, 0, 0, 0, 0 }, { 0, Perl_magic_setenv, 0, Perl_magic_clearenv, 0, 0, 0, 0 }, @@ -102,7 +103,7 @@ EXT_MGVTBL PL_magic_vtables[] = { { 0, 0, 0, Perl_magic_clearhints, 0, 0, 0, 0 } }; #else -EXT_MGVTBL PL_magic_vtables[]; +EXT_MGVTBL PL_magic_vtables[magic_vtable_max]; #endif #define PL_vtbl_amagic PL_magic_vtables[want_vtbl_amagic] |