Cache target distribution version instead of permanently calling rpmdb2solv
authorMichael Andres <ma@suse.de>
Fri, 17 Oct 2008 15:32:16 +0000 (15:32 +0000)
committerMichael Andres <ma@suse.de>
Fri, 17 Oct 2008 15:32:16 +0000 (15:32 +0000)
zypp/target/TargetImpl.cc
zypp/target/TargetImpl.h

index 08d05f2..e661606 100644 (file)
@@ -912,7 +912,15 @@ namespace zypp
     { return rpmdb2solvAttr( "register.release", _root ); }
 
     std::string TargetImpl::distributionVersion() const
-    { return rpmdb2solvAttr( "releasever", _root ); }
+    {
+      if ( _distributionVersion.empty() )
+      {
+        _distributionVersion = rpmdb2solvAttr( "releasever", _root );
+        if ( !_distributionVersion.empty() )
+          MIL << "Remember distributionVersion = '" << _distributionVersion << "'" << endl;
+      }
+      return _distributionVersion;
+    }
 
     ///////////////////////////////////////////////////////////////////
 
index e0b91df..052bcae 100644 (file)
@@ -146,7 +146,7 @@ namespace zypp
 
       /** \copydoc Target::targetDistributionRelease()*/
       std::string targetDistributionRelease() const;
-      
+
       /** \copydoc Target::distributionVersion()*/
       std::string distributionVersion() const;
 
@@ -161,6 +161,8 @@ namespace zypp
       SoftLocksFile _softLocksFile;
       /** Hard-Locks database */
       HardLocksFile _hardLocksFile;
+      /** Cache distributionVersion */
+      mutable std::string _distributionVersion;
     private:
       /** Null implementation */
       static TargetImpl_Ptr _nullimpl;