From 4bbf3dc2097f1de206fa053fac32f675d4ae2927 Mon Sep 17 00:00:00 2001 From: Benjamin Shirley-Quirk Date: Wed, 5 Aug 2020 02:14:46 +0100 Subject: factored out unnecessary NimVersions --- src/common.nim | 78 ++++++++++++++++++++-------------------------------------- 1 file changed, 27 insertions(+), 51 deletions(-) (limited to 'src/common.nim') diff --git a/src/common.nim b/src/common.nim index 0f2804b..f7de141 100644 --- a/src/common.nim +++ b/src/common.nim @@ -153,16 +153,12 @@ proc findSyncTargets*(handle: ptr AlpmHandle, dbs: seq[ptr AlpmDatabase], return @[] else: if allowGroups and target.reference.constraint.isNone: - when NimVersion >= "1.2": - let groupRepo = optFirst: - collect(newSeq): - for d in dbs: - for g in d.groups: - if $g.name == target.reference.name: - d - else: - let groupRepo = lc[d | (d <- dbs, g <- d.groups, - $g.name == target.reference.name), ptr AlpmDatabase].optFirst + let groupRepo = optFirst: + collect(newSeq): + for d in dbs: + for g in d.groups: + if $g.name == target.reference.name: + d if groupRepo.isSome: return @[($groupRepo.unsafeGet.name, none(SyncFoundPackageInfo))] @@ -248,14 +244,10 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona (installed, explicit.toHashSet + assumeExplicit, dependsTable, alternatives) - when NimVersion >= "1.2": - let providedBy = collect(newSeq): - for x in alternatives.namedPairs: - for y in x.value: - (reference:y,name:x.key) - else: - let providedBy = lc[(y, x.key) | (x <- alternatives.namedPairs, y <- x.value), - tuple[reference: PackageReference, name: string]] + let providedBy = collect(newSeq): + for x in alternatives.namedPairs: + for y in x.value: + (reference:y,name:x.key) proc findRequired(withOptional: bool, results: HashSet[string], check: HashSet[string]): HashSet[string] = @@ -273,7 +265,7 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona for x in providedBy: if y.isProvidedBy(x.reference, true): {x.name} - elif NimVersion >= "1.2": + else: let direct = block: var tmp = newSeq[PackageReference]() for y in dependsTable.namedPairs: @@ -289,11 +281,6 @@ proc queryUnrequired*(handle: ptr AlpmHandle, withOptional: bool, withoutOptiona if y.isProvidedBy(x.reference, true): tmp.incl(x.name) tmp - else: - let direct = lc[x.reference | (y <- dependsTable.namedPairs, y.key in check, - x <- y.value, withOptional or not x.optional), PackageReference] - let indirect = lc[x.name | (y <- direct, x <- providedBy, - y.isProvidedBy(x.reference, true)), string].toHashSet let checkNext = (direct.map(p => p.name).toHashSet + indirect) - full if checkNext.len > 0: findRequired(withOptional, full, checkNext) else: full @@ -664,29 +651,21 @@ proc obtainBuildPkgInfosInternal(config: Config, bases: seq[LookupBaseGroup], (list[tuple[pkgInfos: seq[PackageInfo], path: Option[string]]](), 0)) let pkgInfosWithPaths = pkgInfosWithPathsReversed.reversed - when NimVersion >= "1.2": - let pkgInfos = collect(newSeq): - for y in pkgInfosWithPaths: - for x in y.pkgInfos: - x - let paths = collect(newSeq): - for y in pkgInfosWithPaths: - for x in y.path: - x - else: - let pkgInfos = lc[x | (y <- pkgInfosWithPaths, x <- y.pkgInfos), PackageInfo] - let paths = lc[x | (y <- pkgInfosWithPaths, x <- y.path), string] + let pkgInfos = collect(newSeq): + for y in pkgInfosWithPaths: + for x in y.pkgInfos: + x + let paths = collect(newSeq): + for y in pkgInfosWithPaths: + for x in y.path: + x let pkgInfosTable = pkgInfos.map(i => (i.rpc.name, i)).toTable - when NimVersion >= "1.2": - let foundPkgInfos = collect(newSeq): - for y in pacmanTargetNames: - for x in pkgInfosTable.opt(y): - x - else: - let foundPkgInfos = lc[x | (y <- pacmanTargetNames, - x <- pkgInfosTable.opt(y)), PackageInfo] + let foundPkgInfos = collect(newSeq): + for y in pacmanTargetNames: + for x in pkgInfosTable.opt(y): + x let errorMessages = pacmanTargetNames .filter(n => not pkgInfosTable.hasKey(n)) .map(n => tr"$#: failed to get package info" % [n]) @@ -796,13 +775,10 @@ proc cloneAurReposWithPackageInfos*(config: Config, rpcInfos: seq[RpcPackageInfo let (fullPkgInfos, paths, errors) = cloneNext(0, nil, nil, nil) let pkgInfosTable = fullPkgInfos.map(i => (i.rpc.name, i)).toTable - when NimVersion >= "1.2": - let resultPkgInfos = collect(newSeq): - for y in rpcInfos: - for x in pkgInfosTable.opt(y.name): - x - else: - let resultPkgInfos = lc[x | (y <- rpcInfos, x <- pkgInfosTable.opt(y.name)), PackageInfo] + let resultPkgInfos = collect(newSeq): + for y in rpcInfos: + for x in pkgInfosTable.opt(y.name): + x let names = rpcInfos.map(i => i.name).toHashSet let additionalPkgInfos = fullPkgInfos.filter(i => not (i.rpc.name in names)) -- cgit v1.2.3-70-g09d2