Field order should be insignificant between fields of different names

This commit is contained in:
Guoye Zhang committed 2023-08-07 16:14:56 -07:00
1 parent 68deedb6b9
commit 4c7d1331a5
2 files changed
+66 -1

No files matched your search

+23 -1
View File
@@ -108,7 +108,29 @@ public struct HTTPFields: Sendable, Hashable {
}
static func == (lhs: _Storage, rhs: _Storage) -> Bool {
lhs.fields.lazy.map(\.0) == rhs.fields.lazy.map(\.0)
let leftFieldsIndex = lhs.ensureIndex
let rightFieldsIndex = rhs.ensureIndex
if leftFieldsIndex.count != rightFieldsIndex.count {
return false
}
for (name, var leftIndex) in leftFieldsIndex {
guard var rightIndex = rightFieldsIndex[name] else {
return false
}
while leftIndex != .max && rightIndex != .max {
let (leftField, leftNext) = lhs.fields[Int(leftIndex)]
let (rightField, rightNext) = rhs.fields[Int(rightIndex)]
if leftField != rightField {
return false
}
leftIndex = leftNext
rightIndex = rightNext
}
if leftIndex != rightIndex {
return false
}
}
return true
}
func append(field: HTTPField) {