Subject: | [PATCH] Copy-on-write support |
I am currently working on a copy-on-write mechanism for perl 5.18, which in my testing has
shown a 3% speed increase.
Unfortunately it causes test failures, because inflate assumes that the input is a regular string.
If the string is going to be modified in place, it needs to be forced to a string first.
Please consider the attached patch.
Subject: | compress-raw-bzip2-cow.text |
diff --git a/cpan/Compress-Raw-Bzip2/Bzip2.xs b/cpan/Compress-Raw-Bzip2/Bzip2.xs
index d430b24..7010324 100644
--- a/cpan/Compress-Raw-Bzip2/Bzip2.xs
+++ b/cpan/Compress-Raw-Bzip2/Bzip2.xs
@@ -733,8 +733,11 @@ bzinflate (s, buf, output)
/* If the buffer is a reference, dereference it */
buf = deRef(buf, "bzinflate") ;
- if (s->flags & FLAG_CONSUME_INPUT && SvREADONLY(buf))
+ if (s->flags & FLAG_CONSUME_INPUT) {
+ if (SvREADONLY(buf))
croak(UNCOMPRESS_CLASS "::bzinflate input parameter cannot be read-only when ConsumeInput is specified");
+ SvPV_force(buf,PL_na);
+ }
#ifdef UTF8_AVAILABLE
if (DO_UTF8(buf) && !sv_utf8_downgrade(buf, 1))
croak("Wide character in " UNCOMPRESS_CLASS "::bzinflate input parameter");