Currently during Parser::getObj() and when adding values to dictionaries poppler makes unnecessary copies of objects. When objects are strings, this means reallocating memory. Since Parser::getObj() is called (literally) in N*100k times, those memory allocations contribute significantly to the execution time (e.g. delete is 4th most expensive function). The attached patch makes really only two small changes: a) avoid memory copy by giving the caller an ownership of the object and nulling the object in one code path b) optimizing UGooString usage of key variable (it was always constructed but is not always needed) Also adds helper Dict::add* functions to make b) (and maybe other future changes like that) possible.
Created attachment 6797 [details] [review] Patch as described in the bug
Forgot to mention that this patch gives me a consistent ~7% speedup for PDF loading stage.
Commited, thanks, i got a 10% speed increase on the pdf i tested but i guess that is because i don't have the other optimizations so this one gave me more boost to me than to you.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.