Skip to content

Commit

Permalink
perf: make initializing Str from empty string literal as fast as empt…
Browse files Browse the repository at this point in the history
…y array literal
  • Loading branch information
kkebo committed Jun 30, 2024
1 parent 56f9667 commit d3ab446
Showing 1 changed file with 4 additions and 0 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

0 comments on commit d3ab446

Please sign in to comment.