Skip to content

Commit

Permalink
Tiny optimisations
Browse files Browse the repository at this point in the history
Signed-off-by: Ikey Doherty <ikey@solus-project.com>
  • Loading branch information
ikeydoherty committed Nov 28, 2015
1 parent c2af6d3 commit e8d4ea0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pisi/db/installdb.py
Expand Up @@ -261,7 +261,7 @@ def get_package(self, package):
def get_package_by_pkgconfig(self, pkgconfig):
for item in self.list_installed():
pkg = self.get_package(item)
if pkg.providesPkgConfig:
if pkg.providesPkgConfig is not None and len(pkg.providesPkgConfig) > 0:
for pc in pkg.providesPkgConfig:
if pc.om == pkgconfig:
return pkg
Expand Down
2 changes: 1 addition & 1 deletion pisi/db/packagedb.py
Expand Up @@ -87,7 +87,7 @@ def get_package(self, name, repo=None):
def get_package_by_pkgconfig(self, pkgconfig):
for item in self.list_packages(None):
pkg = self.get_package(item)
if pkg.providesPkgConfig:
if pkg.providesPkgConfig is not None and len(pkg.providesPkgConfig) > 0:
for pc in pkg.providesPkgConfig:
if pc.om == pkgconfig:
return pkg
Expand Down
11 changes: 9 additions & 2 deletions pisi/operations/build.py
Expand Up @@ -248,6 +248,7 @@ def __init__(self, specuri):
self.componentdb = pisi.db.componentdb.ComponentDB()
self.installdb = pisi.db.installdb.InstallDB()
self.packagedb = pisi.db.packagedb.PackageDB()
self.filesdb = pisi.db.filesdb.FilesDB()

# process args
if not isinstance(specuri, pisi.uri.URI):
Expand Down Expand Up @@ -975,6 +976,11 @@ def generate_debug_package_object(self, package):

return debug_package_obj

def _search_file(self, term):
if term.startswith("/"):
term = term[1:]
return self.filesdb.search_file(term)

def get_binary_deps(self, path):
bin_deps = list()
if not os.path.exists(path):
Expand Down Expand Up @@ -1021,9 +1027,9 @@ def get_binary_deps(self, path):
result = self._bindeps_cache[dep2]
else:
# First time looking at this dep
result = pisi.api.search_file(dep)
result = self._search_file(dep)
if not result:
result = pisi.api.search_file(dep2)
result = self._search_file(dep2)
if result:
self._bindeps_cache[dep2] = result
else:
Expand Down Expand Up @@ -1062,6 +1068,7 @@ def gen_metadata_xml(self, package):
# on new installed build dependencies
self.installdb = pisi.db.installdb.InstallDB()
self.packagedb = pisi.db.packagedb.PackageDB()
self.filesdb = pisi.db.filesdb.FilesDB()

knownPcFiles = list()
for fileinfo in self.files.list:
Expand Down

0 comments on commit e8d4ea0

Please sign in to comment.