[poppler] std::unique_ptr

Albert Astals Cid aacid at kde.org
Mon May 22 21:34:12 UTC 2017


El dilluns, 22 de maig de 2017, a les 10:37:06 CEST, Carlos Garcia Campos va 
escriure:
> Albert Astals Cid <aacid at kde.org> writes:
> > El diumenge, 21 de maig de 2017, a les 14:20:54 CEST, Carlos Garcia Campos
> > va> 
> > escriure:
> >> I've started to play with using std::unique_ptr in poppler now that we
> >> are using C++11. I've just submitted a new branch unique_ptr on top of
> >> better_object branch. For now I've only changed Annots.
> > 
> > I'm really not a fan of
> > 
> > -    title = obj1.getString()->copy();
> > +    title.reset(obj1.getString()->copy());
> > 
> > my lizard brain does "ctrl+f" and then "title =", when i want to see who
> > is
> > setting title.
> 
> No problem. It can be replaced by:
> 
> title = std::make_unique<GooString>(obj1.getString());
> 
> which is basically the same.

But much nicer to read.

> 
> >> I'll move other
> >> files in follow up commits when I find some more time.
> >> 
> >    if (obj1.isArray()) {
> > 
> > -    interiorColor = new AnnotColor(obj1.getArray());
> > -  } else {
> > -    interiorColor = NULL;
> > +    interiorColor = std::make_unique<AnnotColor>(obj1.getArray());
> > 
> >    }
> > 
> > this will abort if obj1 is not an array.
> 
> Why? There's no change in behavior there. If obj1 is an array, the
> AnnotColor is created, otherwise we don't need to do anything, because
> std::unique_ptr already initializes the pointer to nullptr on
> construction.
> 
Yeah sorry, didn't read the diff correctly.

Cheers,
  Albert

> > Cheers,
> > 
> >   Albert
> >> 
> >> Regards,




More information about the poppler mailing list