Improve indexing performance by using .split instead of .components

and using substrings instead of needlessly copying strings
This commit is contained in:
2024-11-14 19:33:26 +11:00
parent 4c3fb214de
commit 131807709a
2 changed files with 4 additions and 4 deletions

View File

@ -14,7 +14,7 @@ internal struct ApkRequirement: Hashable {
self.versionSpec = spec
}
init(extract: String) throws(ParseError) {
init(extract: Substring) throws(ParseError) {
var comparer: ComparatorBits = []
var dependStr = extract[...]
let nameEnd: String.Index, versionStart: String.Index

View File

@ -75,7 +75,7 @@ extension ApkIndexPackage {
architecture = record.value
case "D":
do {
dependencies = try record.value.components(separatedBy: " ")
dependencies = try record.value.split(separator: " ")
.map { .init(requirement: try .init(extract: $0)) }
} catch { throw .badValue(key: record.key) }
case "C":
@ -95,12 +95,12 @@ extension ApkIndexPackage {
installedSize = value
case "p":
do {
provides = try record.value.components(separatedBy: " ")
provides = try record.value.split(separator: " ")
.map { .init(requirement: try .init(extract: $0)) }
} catch { throw .badValue(key: record.key) }
case "i":
do {
installIf = try record.value.components(separatedBy: " ")
installIf = try record.value.split(separator: " ")
.map { .init(requirement: try .init(extract: $0)) }
} catch { throw .badValue(key: record.key) }
case "o":