Reduce memory footprint of literal strings
Chip Salzenberg [Tue, 1 Apr 1997 00:01:35 +0000 (12:01 +1200)]
(this is the same change as commit 1bd69d1d0fa002def016e601cb71bfcd93600bd3, but as applied)

toke.c

diff --git a/toke.c b/toke.c
index b96e23e..724c214 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -622,7 +622,11 @@ sublex_start()
        return THING;
     }
     if (op_type == OP_CONST || op_type == OP_READLINE) {
-       yylval.opval = (OP*)newSVOP(op_type, 0, q(lex_stuff));
+       SV *sv = q(lex_stuff);
+       STRLEN len;
+       char *p = SvPV(sv, len);
+       yylval.opval = (OP*)newSVOP(op_type, 0, newSVpv(p, len));
+       SvREFCNT_dec(sv);
        lex_stuff = Nullsv;
        return THING;
     }