[Bast-commits] r4450 - in trunk/Devel-Declare: . lib/Devel
matthewt at dev.catalyst.perl.org
matthewt at dev.catalyst.perl.org
Sun Jun 1 11:21:29 BST 2008
Author: matthewt
Date: 2008-06-01 11:21:29 +0100 (Sun, 01 Jun 2008)
New Revision: 4450
Modified:
trunk/Devel-Declare/Declare.xs
trunk/Devel-Declare/lib/Devel/Declare.pm
Log:
reallocate PL_linestr to 8192 chars min in a source filter to avoid need to realloc later (where we can't)
Modified: trunk/Devel-Declare/Declare.xs
===================================================================
--- trunk/Devel-Declare/Declare.xs 2008-06-01 00:29:08 UTC (rev 4449)
+++ trunk/Devel-Declare/Declare.xs 2008-06-01 10:21:29 UTC (rev 4450)
@@ -249,19 +249,7 @@
#endif
SvGROW(PL_linestr, (STRLEN)(old_len + strlen(retstr)));
if (start_diff = SvPVX(PL_linestr) - old_start) {
-#ifdef DD_DEBUG
- printf("linestr realloc'ed, moving stuff about by %i\n", start_diff);
-#endif
- s += start_diff;
- PL_linestart += start_diff;
- PL_bufptr += start_diff;
- PL_bufend += start_diff;
- PL_oldbufptr += start_diff;
- PL_oldoldbufptr += start_diff;
- if (PL_last_lop)
- PL_last_lop += start_diff;
- if (PL_last_uni)
- PL_last_uni += start_diff;
+ Perl_croak("forced to realloc PL_linestr for line %s, bailing out before we crash harder", SvPVX(PL_linestr));
}
memmove(s+strlen(retstr), s, (PL_bufend - s)+1);
memmove(s, retstr, strlen(retstr));
@@ -313,6 +301,14 @@
return o;
}
+static I32 dd_filter_realloc(pTHX_ int idx, SV *sv, int maxlen)
+{
+ const I32 count = FILTER_READ(idx+1, sv, maxlen);
+ SvGROW(sv, 8192); /* please try not to have a line longer than this :) */
+ /* filter_del(dd_filter_realloc); */
+ return count;
+}
+
static int initialized = 0;
MODULE = Devel::Declare PACKAGE = Devel::Declare
@@ -325,15 +321,5 @@
if (!initialized++) {
dd_old_ck_rv2cv = PL_check[OP_RV2CV];
PL_check[OP_RV2CV] = dd_ck_rv2cv;
- dd_old_ck_lineseq = PL_check[OP_LINESEQ];
- PL_check[OP_LINESEQ] = dd_ck_lineseq;
}
-
-void
-teardown()
- CODE:
- /* ensure we only uninit when number of teardown calls matches
- number of setup calls */
- if (initialized && !--initialized) {
- PL_check[OP_RV2CV] = dd_old_ck_rv2cv;
- }
+ filter_add(dd_filter_realloc, NULL);
Modified: trunk/Devel-Declare/lib/Devel/Declare.pm
===================================================================
--- trunk/Devel-Declare/lib/Devel/Declare.pm 2008-06-01 00:29:08 UTC (rev 4449)
+++ trunk/Devel-Declare/lib/Devel/Declare.pm 2008-06-01 10:21:29 UTC (rev 4450)
@@ -63,7 +63,6 @@
my ($class, $target) = @_;
delete $declarators{$target};
delete $declarator_handlers{$target};
- teardown();
}
my $temp_name;
More information about the Bast-commits
mailing list