Skip Menu |

This queue is for tickets about the perl-ldap CPAN distribution.

Report information
The Basics
Id: 22533
Status: resolved
Priority: 0/
Queue: perl-ldap

People
Owner: Nobody in particular
Requestors: R.vanHulsteijn [...] inter.NL.net
Cc:
AdminCc:

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



Subject: performance patch in LDIF.pm
Date: Tue, 24 Oct 2006 10:13:54 +0200 (CEST)
To: bug-perl-ldap [...] rt.cpan.org
From: "Robert van Hulsteijn" <R.vanHulsteijn [...] inter.NL.net>
Distribution: perl-ldap-0.33 Perl: 5.8 OS: Windows 2000 Hi, I found that writing an LDIF record with very long attribute values is extremely slow. I could narrow this problem down to the function _wrap() in the LDIF.pm module. It seems that wrapping the value is quite CPU extensive. The _wrap() routine isn't very efficient in handling long strings. The substr() function seems to be very slow in this case. Using my rewritten _wrap() function speeds up things quite well. Could you please provide this patch to the next release? We've been using this improved function for a while now qith great pleasure. Greetings, Robert ---- old _wrap() ----------------------------- sub _wrap { if($_[1] > 40) { my $pos = $_[1]; while($pos < length($_[0])) { substr($_[0],$pos,0) = "\n "; $pos += $_[1]+1; } } $_[0]; } ---- new _wrap() ----------------------------- sub _wrap { my $string=$_[0]; my $len=$_[1]; my $a=(length($string)-$len>0); my $b=((length($string )-$len)/($len-1)); join("\n ",unpack("a78" x $a . "a77" x $b . "a*",$string)); }