From 9af10bc422a5eefd56fb8e57d55faeba00957662 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Thu, 10 Jul 2014 00:43:42 +0400 Subject: [PATCH] Refactoring: simplification. #70 --- deb/list.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/deb/list.go b/deb/list.go index 1dcc2494..1c5058f2 100644 --- a/deb/list.go +++ b/deb/list.go @@ -334,13 +334,11 @@ func (l *PackageList) PrepareIndex() { } // Search searches package index for specified package -func (l *PackageList) Search(dep Dependency, allMatches bool) []*Package { +func (l *PackageList) Search(dep Dependency, allMatches bool) (searchResults []*Package) { if !l.indexed { panic("list not indexed, can't search") } - searchResults := []*Package{} - if dep.Relation == VersionDontCare { for _, p := range l.providesIndex[dep.Pkg] { if p.MatchesArchitecture(dep.Architecture) { @@ -352,7 +350,7 @@ func (l *PackageList) Search(dep Dependency, allMatches bool) []*Package { } } if len(searchResults) != 0 { - return searchResults + return } } @@ -371,11 +369,7 @@ func (l *PackageList) Search(dep Dependency, allMatches bool) []*Package { i++ } - if len(searchResults) != 0 { - return searchResults - } - - return nil + return } // Filter filters package index by specified queries (ORed together), possibly pulling dependencies