Skip Menu |

This queue is for tickets about the Data-ICal CPAN distribution.

Report information
The Basics
Id: 132352
Status: open
Priority: 0/
Queue: Data-ICal

People
Owner: Nobody in particular
Requestors: rjbs [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: massive speedup in folding code (redux)
Hey, remember that 0.23 fix to make wrapping faster? Turns out that it's -still- slow on very large (100k+) properties, which turn up sometimes. This patch (credit to ROBM, Rob Mueller) is speedup of around two orders of magnitude! ------ --- lib/Data/ICal/Property.pm 2020-01-03 09:12:08.000000000 -0500 +++ lib/Data/ICal/Property.pm.new 2020-04-15 08:32:01.210406228 -0400 @@ -332,9 +332,9 @@ my $out = substr($string, 0, 75, "") . $crlf; - while (length $string) { - my $substr = substr $string, 0, 74, ""; - $out .= " $substr$crlf"; + if (length $string) { + $string =~ s/(.{1,74})/ $1$crlf/g; + $out .= $string; } return $out; ------ Took one export down from 23 minutes to 12 seconds. (!!!) -- rjbs
Just a note the problem really manifests itself when the property is a perl unicode string. The substr($str, 0, $o, “”) bit seems to leave OFFSET set, but other code doesn't seem to use the optimisation correctly, so it ends up O(N^2) when you use it in a loop to repeatedly chop off the front bit (at least on our perl 5.20). Anyway, the s/.../.../g version should work in all cases and appears to be very fast.