From: Andy Lester <andy@petdance.com>
Date: Mon, 3 Jul 2006 17:41:48 +0000 (-0500)
Subject: consting and localizing in universal.c
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3469222433b317d18cea77514faabef96011806b;p=p5sagit%2Fp5-mst-13.2.git

consting and localizing in universal.c
Message-ID: <20060703224148.GA14449@petdance.com>

p4raw-id: //depot/perl@28477
---

diff --git a/embed.fnc b/embed.fnc
index 4f21c27..c965b1a 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -1476,7 +1476,7 @@ s	|void	|printbuf	|NN const char* fmt|NN const char* s
 #endif
 
 #if defined(PERL_IN_UNIVERSAL_C) || defined(PERL_DECL_PROT)
-s	|bool|isa_lookup	|NULLOK HV *stash|NN const char *name|NULLOK HV *name_stash|int len|int level
+s	|bool|isa_lookup	|NULLOK HV *stash|NN const char *name|NULLOK const HV * const name_stash|int len|int level
 #endif
 
 #if defined(PERL_IN_LOCALE_C) || defined(PERL_DECL_PROT)
diff --git a/proto.h b/proto.h
index a060a5c..4272b1d 100644
--- a/proto.h
+++ b/proto.h
@@ -4005,7 +4005,7 @@ STATIC void	S_printbuf(pTHX_ const char* fmt, const char* s)
 #endif
 
 #if defined(PERL_IN_UNIVERSAL_C) || defined(PERL_DECL_PROT)
-STATIC bool	S_isa_lookup(pTHX_ HV *stash, const char *name, HV *name_stash, int len, int level)
+STATIC bool	S_isa_lookup(pTHX_ HV *stash, const char *name, const HV * const name_stash, int len, int level)
 			__attribute__nonnull__(pTHX_2);
 
 #endif
diff --git a/universal.c b/universal.c
index 7cbaaf7..e674d50 100644
--- a/universal.c
+++ b/universal.c
@@ -32,7 +32,7 @@
  */
 
 STATIC bool
-S_isa_lookup(pTHX_ HV *stash, const char *name, HV* name_stash,
+S_isa_lookup(pTHX_ HV *stash, const char *name, const HV* const name_stash,
              int len, int level)
 {
     dVAR;
@@ -45,7 +45,7 @@ S_isa_lookup(pTHX_ HV *stash, const char *name, HV* name_stash,
 
     /* A stash/class can go by many names (ie. User == main::User), so 
        we compare the stash itself just in case */
-    if (name_stash && (stash == name_stash))
+    if (name_stash && ((const HV *)stash == name_stash))
         return TRUE;
 
     hvname = HvNAME_get(stash);
@@ -66,11 +66,12 @@ S_isa_lookup(pTHX_ HV *stash, const char *name, HV* name_stash,
 	&& (hv = GvHV(gv)))
     {
 	if (SvIV(subgen) == (IV)PL_sub_generation) {
-	    SV* sv;
 	    SV** const svp = (SV**)hv_fetch(hv, name, len, FALSE);
-	    if (svp && (sv = *svp) != (SV*)&PL_sv_undef) {
-	        DEBUG_o( Perl_deb(aTHX_ "Using cached ISA %s for package %s\n",
-				  name, hvname) );
+	    if (svp) {
+		SV * const sv = *svp;
+		if (sv != &PL_sv_undef)
+		    DEBUG_o( Perl_deb(aTHX_ "Using cached ISA %s for package %s\n",
+				    name, hvname) );
 		return (sv == &PL_sv_yes);
 	    }
 	}