mirror of
				https://github.com/GayPizzaSpecifications/darwin-apk.git
				synced 2025-11-04 07:59:38 +00:00 
			
		
		
		
	Improve indexing performance by using .split instead of .components
and using substrings instead of needlessly copying strings
This commit is contained in:
		@ -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
 | 
			
		||||
 | 
			
		||||
@ -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":
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user