poppler/Object.h | 13 ------------- poppler/PDFDoc.cc | 2 +- poppler/StructElement.cc | 12 ++++++------ 3 files changed, 7 insertions(+), 20 deletions(-)
New commits: commit fd5c40370d3b950ad8d44760e03c1da443c2d262 Author: Albert Astals Cid <[email protected]> Date: Wed Dec 8 00:40:04 2021 +0100 Remove Object::takeString it's a micro optimization used in non-hot paths and is not even correct due to how GooStrings inside Objects are shared, so just kill it and copy a few strings in those non-hot paths diff --git a/poppler/Object.h b/poppler/Object.h index d5ca59d0..dc4e8baf 100644 --- a/poppler/Object.h +++ b/poppler/Object.h @@ -414,24 +414,11 @@ public: OBJECT_TYPE_CHECK(objString); return string; } - // After takeString() the only method that should be called for the object is free(). - GooString *takeString() - { - OBJECT_TYPE_CHECK(objString); - type = objDead; - return string; - } const GooString *getHexString() const { OBJECT_TYPE_CHECK(objHexString); return string; } - GooString *takeHexString() - { - OBJECT_TYPE_CHECK(objHexString); - type = objDead; - return string; - } const char *getName() const { OBJECT_TYPE_CHECK(objName); diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index 0b694b25..270662a7 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -793,7 +793,7 @@ GooString *PDFDoc::getDocInfoStringEntry(const char *key) GooString *result; if (entryObj.isString()) { - result = entryObj.takeString(); + result = entryObj.getString()->copy(); } else { result = nullptr; } diff --git a/poppler/StructElement.cc b/poppler/StructElement.cc index c44915b4..5246e582 100644 --- a/poppler/StructElement.cc +++ b/poppler/StructElement.cc @@ -921,7 +921,7 @@ void StructElement::parse(Dict *element) // Object ID (optional), to be looked at the IDTree in the tree root. obj = element->lookup("ID"); if (obj.isString()) { - s->id = obj.takeString(); + s->id = obj.getString()->copy(); } // Page reference (optional) in which at least one of the child items @@ -939,31 +939,31 @@ void StructElement::parse(Dict *element) // Element title (optional). obj = element->lookup("T"); if (obj.isString()) { - s->title = obj.takeString(); + s->title = obj.getString()->copy(); } // Language (optional). obj = element->lookup("Lang"); if (obj.isString()) { - s->language = obj.takeString(); + s->language = obj.getString()->copy(); } // Alternative text (optional). obj = element->lookup("Alt"); if (obj.isString()) { - s->altText = obj.takeString(); + s->altText = obj.getString()->copy(); } // Expanded form of an abbreviation (optional). obj = element->lookup("E"); if (obj.isString()) { - s->expandedAbbr = obj.takeString(); + s->expandedAbbr = obj.getString()->copy(); } // Actual text (optional). obj = element->lookup("ActualText"); if (obj.isString()) { - s->actualText = obj.takeString(); + s->actualText = obj.getString()->copy(); } // Attributes directly attached to the element (optional).
