On 24/10/06 10:20, Robert van Hulsteijn <[EMAIL PROTECTED]> wrote: > 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)); > } >
I've just committed this (revision 518) - thanks Robert! Cheers, Chris