]> git.lyx.org Git - features.git/commitdiff
Cache the getInfo() return value. This will matter shortly.
authorRichard Heck <rgheck@comcast.net>
Fri, 16 Jan 2009 23:40:37 +0000 (23:40 +0000)
committerRichard Heck <rgheck@comcast.net>
Fri, 16 Jan 2009 23:40:37 +0000 (23:40 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28190 a592a061-630c-0410-9148-cb99ea01b6c8

src/BiblioInfo.cpp
src/BiblioInfo.h

index 68d37e83e2914988dcca04ae364f0cc6f2ac8fcd..7251649f5a8bee6b07d1612ab6d8e108c50a8592 100644 (file)
@@ -175,9 +175,13 @@ docstring const BibTeXInfo::getYear() const
 
 docstring const BibTeXInfo::getInfo() const
 {
+       if (!info_.empty())
+               return info_;
+
        if (!is_bibtex_) {
                BibTeXInfo::const_iterator it = find(from_ascii("ref"));
-               return it->second;
+               info_ = it->second;
+               return info_;
        }
  
        // FIXME
@@ -224,8 +228,10 @@ docstring const BibTeXInfo::getInfo() const
                result << ", " << docLoc;
 
        docstring const result_str = rtrim(result.str());
-       if (!result_str.empty())
-               return result_str;
+       if (!result_str.empty()) {
+               info_ = result_str;
+               return info_;
+       }
 
        // This should never happen (or at least be very unusual!)
        return docstring();
index 0baa06c5c2d97b57d7e5122a081282ac1d54d63b..f0a9b1180e5916f69e447b9865ffa39c9a06ffa7 100644 (file)
@@ -92,6 +92,8 @@ private:
        docstring all_data_;
        /// the BibTeX entry type (article, book, incollection, ...)
        docstring entry_type_;
+       /// a cache for getInfo()
+       mutable docstring info_;
        /// our map: <field, value>
        std::map <docstring, docstring> bimap_;
 };