Subject: | PDF::API object creation takes a lot of time when cross reference table is huge |
Date: | Wed, 22 Jul 2009 18:46:24 +0530 |
To: | <bug-pdf-api3 [...] rt.cpan.org> |
From: | "Abhinav Kaushik" <Abhinavk [...] stratify.com> |
There is a scope for improvement in cross reference table parsing. It
takes a lot of time for PDF files with large number of objects. Eg pdf
reference document "PDF reference sixth edition version 1.7"
Suggested improvement:
PDF\API2\Basic\PDF\File.pm
1214c1214,1216
< while ($xnum-- > 0 && $buf =~
s/^0*([0-9]*)$ws_char+0*([0-9]+)$ws_char+([nf])$cr//o)
---
Show quoted text
>
> my $cnt = 0;
> while ($xnum-- > 0 && (my $row = substr $buf, $cnt*20, 20))
1216c1218,1222
< $xlist->{$xmin} = [$1, $2, $3] unless(exists
$xlist->{$xmin});
---
Show quoted text> $cnt += 1;
> my $offset = substr $row, 0, 10;
> my $gen = substr $row, 11, 5;
> my $f = substr $row, 17, 1;
> $xlist->{$xmin} = [$offset, $gen, $f] unless(exists
$xlist->{$xmin});
1218a1225,1227
Show quoted text> $buf = substr $buf, $cnt*20;
>
>