Don't call strlen() twice on the same string.
[p5sagit/Devel-Declare.git] / Declare.xs
index 76d70dd..9b10cc4 100644 (file)
@@ -120,10 +120,10 @@ void dd_set_linestr(pTHX_ char* new_value) {
   int new_len = strlen(new_value);
   char* old_linestr = SvPVX(PL_linestr);
 
-  SvGROW(PL_linestr, strlen(new_value));
+  SvGROW(PL_linestr, new_len);
 
   if (SvPVX(PL_linestr) != old_linestr)
-    Perl_croak(aTHX_ "forced to realloc PL_linestr for line %s, bailing out before we crash harder", SvPVX(PL_linestr));
+    croak("forced to realloc PL_linestr for line %s, bailing out before we crash harder", SvPVX(PL_linestr));
 
   memcpy(SvPVX(PL_linestr), new_value, new_len+1);
 
@@ -138,7 +138,7 @@ char* dd_get_lex_stuff(pTHX) {
 
 char* dd_clear_lex_stuff(pTHX) {
   if (DD_HAVE_PARSER)
-    PL_lex_stuff = Nullsv;
+    PL_lex_stuff = (SV*)NULL;
 }
 
 char* dd_get_curstash_name(pTHX) {
@@ -304,7 +304,7 @@ STATIC OP *dd_ck_const(pTHX_ OP *o) {
   /* if this is set, we just grabbed a delimited string or something,
      not a bareword, so NO TOUCHY */
 
-  if (PL_lex_stuff)
+  if (DD_HAVE_LEX_STUFF)
     return o;
 
   /* don't try and look this up if it's not a string const */