Optimize rpmstrPool usage
Introduce global rpmstrPool object and make all rpmds constructors use it.
This commit is contained in:
parent
7fbdefdcc2
commit
faf04db603
@ -53,6 +53,8 @@ libapt_pkg_la_SOURCES = \
|
||||
rpm/rpmrecords.h \
|
||||
rpm/rpmsrcrecords.cc \
|
||||
rpm/rpmsrcrecords.h \
|
||||
rpm/rpmstrPool.cc \
|
||||
rpm/rpmstrPool.h \
|
||||
rpm/rpmsystem.cc \
|
||||
rpm/rpmsystem.h \
|
||||
rpm/rpmversion.cc \
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <apt-pkg/rpmhandler.h>
|
||||
#include <apt-pkg/rpmpackagedata.h>
|
||||
#include <apt-pkg/rpmsystem.h>
|
||||
#include <apt-pkg/rpmstrPool.h>
|
||||
#include <apt-pkg/error.h>
|
||||
#include <apt-pkg/configuration.h>
|
||||
#include <apt-pkg/strutl.h>
|
||||
@ -460,9 +461,9 @@ bool rpmListParser::ParseDepends(pkgCache::VerIterator Ver,
|
||||
{
|
||||
#if RPM_VERSION >= 0x040404
|
||||
rpmds rpmlibProv = NULL;
|
||||
rpmds ds = rpmdsSingle(RPMTAG_PROVIDENAME,
|
||||
namel[i], verl?verl[i]:NULL, flagl[i]);
|
||||
rpmdsRpmlib(&rpmlibProv, NULL);
|
||||
rpmds ds = dsSingleGlobal(RPMTAG_PROVIDENAME,
|
||||
namel[i], verl?verl[i]:NULL, flagl[i]);
|
||||
dsRpmlibGlobal(&rpmlibProv, NULL);
|
||||
int res = rpmdsSearch(rpmlibProv, ds) >= 0;
|
||||
rpmdsFree(ds);
|
||||
rpmdsFree(rpmlibProv);
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <apt-pkg/error.h>
|
||||
#include <apt-pkg/strutl.h>
|
||||
#include <apt-pkg/rpmhandler.h>
|
||||
#include <apt-pkg/rpmstrPool.h>
|
||||
#include <apt-pkg/pkgcache.h>
|
||||
|
||||
#include <apti18n.h>
|
||||
@ -514,9 +515,9 @@ bool rpmSrcRecordParser::BuildDepends(vector<pkgSrcRecords::Parser::BuildDepRec>
|
||||
{
|
||||
#if RPM_VERSION >= 0x040404
|
||||
rpmds rpmlibProv = NULL;
|
||||
rpmds ds = rpmdsSingle(RPMTAG_PROVIDENAME,
|
||||
namel[i], verl?verl[i]:NULL, flagl[i]);
|
||||
rpmdsRpmlib(&rpmlibProv, NULL);
|
||||
rpmds ds = dsSingleGlobal(RPMTAG_PROVIDENAME,
|
||||
namel[i], verl?verl[i]:NULL, flagl[i]);
|
||||
dsRpmlibGlobal(&rpmlibProv, NULL);
|
||||
int res = (rpmdsSearch(rpmlibProv, ds) != -1);
|
||||
rpmdsFree(ds);
|
||||
rpmdsFree(rpmlibProv);
|
||||
|
21
apt/apt-pkg/rpm/rpmstrPool.cc
Normal file
21
apt/apt-pkg/rpm/rpmstrPool.cc
Normal file
@ -0,0 +1,21 @@
|
||||
#include <apt-pkg/rpmstrPool.h>
|
||||
#include <rpm/rpmstrpool.h>
|
||||
|
||||
static rpmstrPool global_rpmstrPool;
|
||||
|
||||
rpmds dsSingleGlobal(rpmTagVal tagN, const char * N, const char * EVR,
|
||||
rpmsenseFlags Flags)
|
||||
{
|
||||
if (!global_rpmstrPool)
|
||||
global_rpmstrPool = rpmstrPoolCreate();
|
||||
|
||||
return rpmdsSinglePool(global_rpmstrPool, tagN, N, EVR, Flags);
|
||||
}
|
||||
|
||||
int dsRpmlibGlobal(rpmds * dsp, const void * tblp)
|
||||
{
|
||||
if (!global_rpmstrPool)
|
||||
global_rpmstrPool = rpmstrPoolCreate();
|
||||
|
||||
return rpmdsRpmlibPool(global_rpmstrPool, dsp, tblp);
|
||||
}
|
8
apt/apt-pkg/rpm/rpmstrPool.h
Normal file
8
apt/apt-pkg/rpm/rpmstrPool.h
Normal file
@ -0,0 +1,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <rpm/rpmtypes.h>
|
||||
#include <rpm/rpmds.h>
|
||||
|
||||
rpmds dsSingleGlobal(rpmTagVal tagN, const char * N, const char * EVR,
|
||||
rpmsenseFlags Flags);
|
||||
|
||||
int dsRpmlibGlobal(rpmds * dsp, const void * tblp);
|
@ -20,6 +20,7 @@
|
||||
#ifdef HAVE_RPM
|
||||
|
||||
#include <apt-pkg/rpmversion.h>
|
||||
#include <apt-pkg/rpmstrPool.h>
|
||||
#include <apt-pkg/pkgcache.h>
|
||||
|
||||
#include <rpm/rpmlib.h>
|
||||
@ -207,8 +208,8 @@ bool rpmVersioningSystem::CheckDep(const char *PkgVer,
|
||||
return invert ? false : true;
|
||||
|
||||
#if RPM_VERSION >= 0x040100
|
||||
rpmds pds = rpmdsSingle(RPMTAG_PROVIDENAME, "", PkgVer, PkgFlags);
|
||||
rpmds dds = rpmdsSingle(RPMTAG_REQUIRENAME, "", DepVer, DepFlags);
|
||||
rpmds pds = dsSingleGlobal(RPMTAG_PROVIDENAME, "", PkgVer, PkgFlags);
|
||||
rpmds dds = dsSingleGlobal(RPMTAG_REQUIRENAME, "", DepVer, DepFlags);
|
||||
#if RPM_VERSION >= 0x040201
|
||||
rpmdsSetNoPromote(pds, _rpmds_nopromote);
|
||||
rpmdsSetNoPromote(dds, _rpmds_nopromote);
|
||||
|
Loading…
Reference in New Issue
Block a user