Skip to content

Commit

Permalink
Merge pull request #84 from kkebo/use-string-literal-2
Browse files Browse the repository at this point in the history
  • Loading branch information
kkebo authored Jul 1, 2024
2 parents 6387067 + d3ab446 commit b919988
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions Sources/Tokenizer/Str.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ public typealias Char = Unicode.Scalar

extension Str: @retroactive ExpressibleByStringLiteral {
@inlinable public init(stringLiteral value: consuming String) {
guard !value.isEmpty else {
self = []
return
}
self.init(value.unicodeScalars)
}
}
Expand Down
14 changes: 7 additions & 7 deletions Sources/Tokenizer/Tokenizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public struct Tokenizer<Sink: ~Copyable & TokenSink>: ~Copyable {
self.emitsAllErrors = emitsAllErrors
self.state = .data
self.reconsumeChar = nil
self.tempBuffer = []
self.currentComment = []
self.currentTagName = []
self.tempBuffer = ""
self.currentComment = ""
self.currentTagName = ""
self.currentTagKind = .start
self.currentAttrName = []
self.currentAttrValue = []
self.currentAttrName = ""
self.currentAttrValue = ""
self.currentAttrs = [:]
self.lastStartTagName = nil
self.currentDOCTYPE = .init()
Expand Down Expand Up @@ -1506,7 +1506,7 @@ public struct Tokenizer<Sink: ~Copyable & TokenSink>: ~Copyable {
private mutating func clearPublicID() {
switch self.currentDOCTYPE.publicID {
case .some: self.currentDOCTYPE.publicID?.removeAll(keepingCapacity: true)
case .none: self.currentDOCTYPE.publicID = []
case .none: self.currentDOCTYPE.publicID = ""
}
}

Expand All @@ -1522,7 +1522,7 @@ public struct Tokenizer<Sink: ~Copyable & TokenSink>: ~Copyable {
private mutating func clearSystemID() {
switch self.currentDOCTYPE.systemID {
case .some: self.currentDOCTYPE.systemID?.removeAll(keepingCapacity: true)
case .none: self.currentDOCTYPE.systemID = []
case .none: self.currentDOCTYPE.systemID = ""
}
}

Expand Down

0 comments on commit b919988

Please sign in to comment.