Annot: save some unneeded copy() calls
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 80e3a99..0ebde31 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -929,7 +929,7 @@
}
// Test if stateObj (a Ref or a Dict) points to the specified stream
-bool AnnotAppearance::referencesStream(Object *stateObj, Ref refToStream) {
+bool AnnotAppearance::referencesStream(const Object *stateObj, Ref refToStream) {
if (stateObj->isRef()) {
Ref r = stateObj->getRef();
if (r.num == refToStream.num && r.gen == refToStream.gen) {
@@ -952,22 +952,21 @@
// Test if this AnnotAppearance references the specified stream
bool AnnotAppearance::referencesStream(Ref refToStream) {
- Object obj1;
bool found;
// Scan each state's ref/subdictionary
- obj1 = appearDict.dictLookupNF("N").copy();
- found = referencesStream(&obj1, refToStream);
+ const Object &objN = appearDict.dictLookupNF("N");
+ found = referencesStream(&objN, refToStream);
if (found)
return true;
- obj1 = appearDict.dictLookupNF("R").copy();
- found = referencesStream(&obj1, refToStream);
+ const Object &objR = appearDict.dictLookupNF("R");
+ found = referencesStream(&objR, refToStream);
if (found)
return true;
- obj1 = appearDict.dictLookupNF("D").copy();
- found = referencesStream(&obj1, refToStream);
+ const Object &objD = appearDict.dictLookupNF("D");
+ found = referencesStream(&objD, refToStream);
return found;
}
@@ -995,7 +994,7 @@
}
// Removes stream if obj is a Ref, or removes pointed streams if obj is a Dict
-void AnnotAppearance::removeStateStreams(Object *obj1) {
+void AnnotAppearance::removeStateStreams(const Object *obj1) {
if (obj1->isRef()) {
removeStream(obj1->getRef());
} else if (obj1->isDict()) {
@@ -1010,13 +1009,12 @@
}
void AnnotAppearance::removeAllStreams() {
- Object obj1;
- obj1 = appearDict.dictLookupNF("N").copy();
- removeStateStreams(&obj1);
- obj1 = appearDict.dictLookupNF("R").copy();
- removeStateStreams(&obj1);
- obj1 = appearDict.dictLookupNF("D").copy();
- removeStateStreams(&obj1);
+ const Object &objN = appearDict.dictLookupNF("N");
+ removeStateStreams(&objN);
+ const Object &objR = appearDict.dictLookupNF("R");
+ removeStateStreams(&objR);
+ const Object &objD = appearDict.dictLookupNF("D");
+ removeStateStreams(&objD);
}
//------------------------------------------------------------------------
diff --git a/poppler/Annot.h b/poppler/Annot.h
index 4fbdcda..0916986 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -21,7 +21,7 @@
// Copyright (C) 2008 Hugo Mercier <hmercier31@gmail.com>
// Copyright (C) 2008 Pino Toscano <pino@kde.org>
// Copyright (C) 2008 Tomas Are Haavet <tomasare@gmail.com>
-// Copyright (C) 2009-2011, 2013, 2016-2018 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2009-2011, 2013, 2016-2019 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2012, 2013 Fabio D'Urso <fabiodurso@hotmail.it>
// Copyright (C) 2012, 2015 Tobias Koenig <tokoe@kdab.com>
// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
@@ -446,9 +446,9 @@
bool referencesStream(Ref targetStreamRef);
private:
- static bool referencesStream(Object *stateObj, Ref targetStreamRef);
+ static bool referencesStream(const Object *stateObj, Ref targetStreamRef);
void removeStream(Ref refToStream);
- void removeStateStreams(Object *state);
+ void removeStateStreams(const Object *state);
protected:
PDFDoc *doc;