From c7fdacb978df1723dbbd70b5517ff77db208a23e Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Fri, 13 May 2011 21:21:49 +0100 Subject: 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[]. --- mg_vtable.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'mg_vtable.h') 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] -- cgit v1.2.1