Author: matz
Date: Thu Feb 14 12:37:51 2008
New Revision: 8677
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8677&view=rev
Log:
Make byIdent{Begin,End} an indexed iterator globally, remove PoolIndex
from doUpgrade.
Modified:
branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.cc
branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.h
branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.h
branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolTraits.h
branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.cc?rev=8677&r1=8676&r2=8677&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.cc Thu Feb 14 12:37:51 2008
@@ -101,6 +101,9 @@
const pool::PoolTraits::ItemContainerT & ResPool::store() const
{ return _pimpl->store(); }
+ const pool::PoolTraits::Id2ItemT & ResPool::id2item() const
+ { return _pimpl->id2item(); }
+
/******************************************************************
**
** FUNCTION NAME : operator<<
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.h?rev=8677&r1=8676&r2=8677&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ResPool.h Thu Feb 14 12:37:51 2008
@@ -112,56 +112,71 @@
/** \name Iterate through all PoolItems of a certain name and kind. */
//@{
typedef pool::ByIdent ByIdent;
- typedef filter_iterator byIdent_iterator;
+ typedef pool::PoolTraits::Id2ItemT Id2ItemT;
+ typedef transform_iteratorId2ItemT::value_type, Id2ItemT::const_iterator> byIdent_iterator;
+
+ byIdent_iterator byIdentBegin( sat::detail::IdType id ) const
+ {
+ std::pair it2
+ = id2item().equal_range(id);
+ return make_transform_iterator(it2.first, std::_Select2ndId2ItemT::value_type());
+ }
+
+ byIdent_iterator byIdentEnd( sat::detail::IdType id ) const
+ {
+ std::pair it2
+ = id2item().equal_range(id);
+ return make_transform_iterator(it2.second, std::_Select2ndId2ItemT::value_type());
+ }
byIdent_iterator byIdentBegin( ResKind kind_r, IdString name_r ) const
- { return make_filter_begin( ByIdent(kind_r,name_r), *this ); }
+ { return byIdentBegin( ByIdent(kind_r,name_r).get() ); }
byIdent_iterator byIdentBegin( ResKind kind_r, const C_Str & name_r ) const
- { return make_filter_begin( ByIdent(kind_r,name_r), *this ); }
+ { return byIdentBegin( ByIdent(kind_r,name_r).get() ); }
template<class _Res>
byIdent_iterator byIdentBegin( IdString name_r ) const
- { return make_filter_begin( ByIdent(ResTraits<_Res>::kind,name_r), *this ); }
+ { return byIdentBegin( ByIdent(ResTraits<_Res>::kind,name_r).get() ); }
template<class _Res>
byIdent_iterator byIdentBegin( const C_Str & name_r ) const
- { return make_filter_begin( ByIdent(ResTraits<_Res>::kind,name_r), *this ); }
+ { return byIdentBegin( ByIdent(ResTraits<_Res>::kind,name_r).get() ); }
/** Derive name and kind from \ref PoolItem. */
byIdent_iterator byIdentBegin( const PoolItem & pi_r ) const
- { return make_filter_begin( ByIdent(pi_r.satSolvable()), *this ); }
+ { return byIdentBegin( ByIdent(pi_r.satSolvable()).get() ); }
/** Derive name and kind from \ref sat::Solvable. */
byIdent_iterator byIdentBegin( sat::Solvable slv_r ) const
- { return make_filter_begin( ByIdent(slv_r), *this ); }
+ { return byIdentBegin( ByIdent(slv_r).get() ); }
/** Takes a \ref sat::Solvable::ident string. */
byIdent_iterator byIdentBegin( IdString ident_r ) const
- { return make_filter_begin( ByIdent(ident_r), *this ); }
+ { return byIdentBegin( ByIdent(ident_r).get() ); }
byIdent_iterator byIdentEnd( ResKind kind_r, IdString name_r ) const
- { return make_filter_end( ByIdent(kind_r,name_r), *this ); }
+ { return byIdentEnd( ByIdent(kind_r,name_r).get() ); }
byIdent_iterator byIdentEnd( ResKind kind_r, const C_Str & name_r ) const
- { return make_filter_end( ByIdent(kind_r,name_r), *this ); }
+ { return byIdentEnd( ByIdent(kind_r,name_r).get() ); }
template<class _Res>
byIdent_iterator byIdentEnd( IdString name_r ) const
- { return make_filter_end( ByIdent(ResTraits<_Res>::kind,name_r), *this ); }
+ { return byIdentEnd( ByIdent(ResTraits<_Res>::kind,name_r).get() ); }
template<class _Res>
byIdent_iterator byIdentEnd( const C_Str & name_r ) const
- { return make_filter_end( ByIdent(ResTraits<_Res>::kind,name_r), *this ); }
+ { return byIdentEnd( ByIdent(ResTraits<_Res>::kind,name_r).get() ); }
/** Derive name and kind from \ref PoolItem. */
byIdent_iterator byIdentEnd( const PoolItem & pi_r ) const
- { return make_filter_end( ByIdent(pi_r.satSolvable()), *this ); }
+ { return byIdentEnd( ByIdent(pi_r.satSolvable()).get() ); }
/** Derive name and kind from \ref sat::Solvable. */
byIdent_iterator byIdentEnd( sat::Solvable slv_r ) const
- { return make_filter_end( ByIdent(slv_r), *this ); }
+ { return byIdentEnd( ByIdent(slv_r).get() ); }
/** Takes a \ref sat::Solvable::ident string. */
byIdent_iterator byIdentEnd( IdString ident_r ) const
- { return make_filter_end( ByIdent(ident_r), *this ); }
+ { return byIdentEnd( ByIdent(ident_r).get() ); }
//@}
public:
@@ -286,6 +301,7 @@
private:
const pool::PoolTraits::ItemContainerT & store() const;
+ const pool::PoolTraits::Id2ItemT & id2item() const;
private:
/** Ctor */
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.h?rev=8677&r1=8676&r2=8677&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolImpl.h Thu Feb 14 12:37:51 2008
@@ -47,6 +47,7 @@
typedef PoolTraits::ItemContainerT ContainerT;
typedef PoolTraits::size_type size_type;
typedef PoolTraits::const_iterator const_iterator;
+ typedef PoolTraits::Id2ItemT Id2ItemT;
typedef sat::detail::SolvableIdType SolvableIdType;
@@ -237,6 +238,30 @@
return _store;
}
+ const Id2ItemT & id2item () const
+ {
+ checkSerial();
+ if (_id2itemDirty)
+ {
+ _id2itemDirty = false;
+ store();
+ _id2item = Id2ItemT(size());
+ const_iterator it = make_filter_begin( ByPoolItem(), store() );
+ const_iterator e = make_filter_end( ByPoolItem(), store() );
+ for (; it != e; ++it)
+ {
+ sat::detail::IdType id;
+ const sat::Solvable &s = (*it)->satSolvable();
+ id = s.ident().id();
+ if (s.isKind( ResKind::srcpackage ))
+ id = -id;
+ _id2item.insert(std::make_pair(id, *it));
+ }
+ }
+ return _id2item;
+ }
+
+
///////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////
@@ -250,6 +275,8 @@
void invalidate() const
{
_storeDirty = true;
+ _id2itemDirty = true;
+ _id2item.clear();
_poolProxy.reset();
_knownRepositoriesPtr.reset();
}
@@ -259,6 +286,8 @@
SerialNumberWatcher _watcher;
mutable ContainerT _store;
mutable DefaultIntegral _storeDirty;
+ mutable Id2ItemT _id2item;
+ mutable DefaultIntegral _id2itemDirty;
private:
mutable AdditionalCapabilities _additionalRequire;
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolTraits.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolTraits.h?rev=8677&r1=8676&r2=8677&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolTraits.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/pool/PoolTraits.h Thu Feb 14 12:37:51 2008
@@ -14,6 +14,7 @@
#include <set>
#include <map>
+#include
#include "zypp/base/Iterator.h"
@@ -130,6 +131,7 @@
typedef filter_iterator
const_iterator;
typedef ItemContainerT::size_type size_type;
+ typedef std::tr1::unordered_multimap Id2ItemT;
// internal organization
typedef std::listzypp::CapAndItem CapItemContainerT; // (why,who) pairs
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc?rev=8677&r1=8676&r2=8677&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc Thu Feb 14 12:37:51 2008
@@ -70,27 +70,6 @@
using namespace std;
using namespace zypp;
-struct PoolIndex
-{
- PoolIndex()
- {
- ResPool pool( ResPool::instance() );
- for_( it, pool.begin(), pool.end() )
- _cache[it->satSolvable().ident()].push_back( *it );
- }
-
- std::vector<PoolItem> & get( const PoolItem & pi )
- { return get( pi.satSolvable().ident() ); }
-
- std::vector<PoolItem> & get( sat::Solvable slv_r )
- { return get( slv_r.ident() );}
-
- std::vector<PoolItem> & get( IdString ident_r )
- { return _cache[ident_r]; }
-
- std::map _cache;
-};
-
/** Order on AvialableItemSet.
* \li best Arch
* \li best Edition
@@ -364,7 +343,6 @@
}
/* Find upgrade candidates for each package. */
- PoolIndex identIndex;
for ( ResPool::const_iterator it = _pool.begin(); it != _pool.end(); ++it ) {
PoolItem item = *it;
@@ -391,7 +369,7 @@
candidate = cand_it->second; // found candidate already
}
else {
- candidate = Helper::findUpdateItem( identIndex.get( installed ), installed ); // find 'best' upgrade candidate
+ candidate = Helper::findUpdateItem( _pool, installed ); // find 'best' upgrade candidate
}
if (!candidate) {
MIL << "doUpgrade available: SKIP no candidate for " << installed << endl;
@@ -412,7 +390,7 @@
}
candidate = item;
candidate.status().setSeen(true); // mark as seen
- installed = Helper::findInstalledItem( identIndex.get( candidate ), candidate );
+ installed = Helper::findInstalledItem( _pool, candidate );
if (installed) { // check if we already have an installed
if ( installed.status().isLocked() ) {
MIL << "doUpgrade available: SKIP candidate " << candidate << ", locked " << installed << endl;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org