Skip to content

Commit

Permalink
perf: avoid reallocations
Browse files Browse the repository at this point in the history
  • Loading branch information
kkebo committed May 20, 2024
1 parent 697e587 commit 88ed55a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Sources/Tokenizer/Tokenizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1502,9 +1502,13 @@ public struct Tokenizer<Sink: ~Copyable & TokenSink>: ~Copyable {
}
}

// swift-format-ignore: NeverForceUnwrap
@inline(__always)
private mutating func clearPublicID() {
self.currentDOCTYPE.publicID = []
switch self.currentDOCTYPE.publicID {
case .some: self.currentDOCTYPE.publicID!.removeAll(keepingCapacity: true)
case .none: self.currentDOCTYPE.publicID = []
}
}

@inline(__always)
Expand All @@ -1515,9 +1519,13 @@ public struct Tokenizer<Sink: ~Copyable & TokenSink>: ~Copyable {
}
}

// swift-format-ignore: NeverForceUnwrap
@inline(__always)
private mutating func clearSystemID() {
self.currentDOCTYPE.systemID = []
switch self.currentDOCTYPE.systemID {
case .some: self.currentDOCTYPE.systemID!.removeAll(keepingCapacity: true)
case .none: self.currentDOCTYPE.systemID = []
}
}

@inline(__always)
Expand Down

0 comments on commit 88ed55a

Please sign in to comment.