mirror of
https://github.com/apple/swift-http-types
synced 2026-11-30 05:18:47 +00:00
Reimplement HTTPFields on top of a simple Array (#138)
### Motivation We like faster and simpler code. When optimizing performance we focus on often used use-cases. ### Changes - Reimplement HTTPFields on top of a simple Array ### Result - HTTPFields building becomes significantly faster - HTTPFields lookups are faster for small fields, and only slightly slower for larger (nearly always offset by reduced build time) Follow ups: - Make the equality implementation smarter
This commit is contained in:
1 parent
4b1dd0cab3
commit
43cf84fb56
113 files changed
+225
-505
No files matched your search
@@ -34,6 +34,16 @@ extension HTTPField.Name {
|
||||
#expect(fields[values: .acceptEncodingUpper].count == 3)
|
||||
}
|
||||
|
||||
@Test func contains() {
|
||||
var fields = HTTPFields()
|
||||
fields[.acceptEncoding] = "gzip"
|
||||
|
||||
#expect(fields.contains(.acceptEncoding))
|
||||
#expect(fields.contains(.acceptEncodingMixed))
|
||||
#expect(fields.contains(.acceptEncodingUpper))
|
||||
#expect(!fields.contains(.accept))
|
||||
}
|
||||
|
||||
@Test func fieldValue() {
|
||||
#expect(HTTPField(name: .accept, value: " \n 😀 \t ").value == "😀")
|
||||
#expect(HTTPField(name: .accept, value: " a 😀 \t\n b \t \r ").value == "a 😀 \t b")
|
||||
|
||||
Reference in new issue
Block a user