[poppler] [PATCH] ~10% speedup for loading/parsing a PDF file
through simple GooString optimization
Reece Dunn
msclrhd at hotmail.com
Mon Aug 14 11:28:22 PDT 2006
Leonard Rosenthol wrote:
> At 10:37 AM 8/14/2006, Reece Dunn wrote:
> > > What about using a smart pointer? Something as simple as
> > > std::auto_ptr<> for a start - or possibly going all the way to
> > > boost::shared_ptr<>.
> >
> >These won't work as you need to call Object::release()
>
> No you don't. That's all automatic in the destructor -
> EXACTLY what you want. Go check it out ;).
I was thinking of Object::free(), and it isn't called in the destructor. For
example, in XRef.cc (line 94):
if (!objStr.streamGetDict()->lookup("N", &obj1)->isInt()) {
obj1.free();
goto err1;
}
nObjects = obj1.getInt();
obj1.free();
That is, you need to explicitly call copy/free for deep object copy which
is used a lot in the codebase. There is also use of the shallow copy via
operator=, making it impossible to move free() into the destructor.
I know that there are shallow copies in there as I have tried moving the
logic of obj.free() into the destructor and failed!
> >I have made several attempts at cleaning up the XPDF codebase
> >as it does not make use of the C++ library (GooString vs. std::string,
> >GooList vs. std::list, qsort vs. std::sort),
>
> Yes, that's painful indeed. However, can we safely assume
> that all platforms on which Poppler would be used (including
> embedded) are up to date?
I can see that in this instance, compilers may not support std::string
or STL.
> > uses goto for resource
> >cleanup instead of RAII (Resource Aquisition Is Initialization - i.e.
> >constructors aquire a resource, destructors clean that resource up),
> >etc.
>
> Yeah, it makes for VERY ugly code...
The code quality can be greatly improved without sacrificing compiler
support.
> >Q: Is there any point in having GBool/gTrue/gFalse now since only
> >the very ancient of C++ compilers don't support bool/true/false?
>
> See above.
>From what I can remember, gcc 2.95 has bool support (not sure
about earlier versions), so that covers most old Linux and Mac
distributions. Metrowerks CodeWarrior for Mac/Windows would
require a very old version - even V6 has it. With Microsoft VC++,
VC6 has bool support, although I am not sure about VC5.
The compilers that will have a problem with bool are those that
are 8-10 years old or older.
Do you know where the list of supported platforms/compilers
is for Poppler? That would help determine what is and is not
possible.
- Reece
_________________________________________________________________
Be one of the first to try Windows Live Mail.
http://ideas.live.com/programpage.aspx?versionId=5d21c51a-b161-4314-9b0e-4911fb2b2e6d
More information about the poppler
mailing list