### Motivation
Checking for equality of multiple http fields creates an array per field
name. However, not every field will actually have multiple values, which
means we can save array allocations for fields that are only set once.
### Modifications
- Added an enum to handle single values without extra allocations
### Result
Faster equality checks.
## Summary
HTTPFields equality does not depend on the order of differently named
fields. Hashing used storage order, so equal values could hash
differently.
This hashes each name group in relative order, then mixes those group
hashes without depending on name order. The existing hash test now
asserts equal hashes.
Fixes#139
### Motivation
We want to have fast code.
### Changes
Add `@inlinable` to a number of functions, to allow better compiler
optimizations.
### Result
Improvements in some benchmarks
### Motivation
#138 introduced code paths that scale quadratically when running an
equality check.
### Changes
- Introduce a new lock-step equality check that performs great for small
fields and fields that share roughly the same order
- Introduce a new lookup equality check that scales linear for vastly
different field orders
### Result
Faster equality checks
### 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
### Motivation
`_Storage.append(field:)` updated the name index through optional
chaining:
self.index?[name, default: (first: location, last: 0)].last = location
The optional chaining self.index? is expanded into
if var index = self.index {
index[name, default: (first: location, last: 0)].last = location // this
allocates – as dict is referenced by self.index and index
self.index = index
}
Because of this we have an allocation on every append.
### Changes
Nil-check `self.index` once, then mutate through the force-unwrapped
`self.index![name] = ...`, which is an addressable projection of the
stored property and mutates in place.
### Result
Allocations drop on every append-driven path.
Motivation:
Swift 6.0 is no longer supported, we should bump the tools version and
remove it from our CI.
Modifications:
* Bump the Swift tools version to Swift 6.1
* Remove Swift 6.0 jobs where appropriate in main.yml, pull_request.yml
Result:
Code reflects our support window.
---------
Co-authored-by: Guoye Zhang <guoye_zhang@apple.com>
# Motivation
We just adopted GH actions and want to make sure all the CI checks are green.
# Modification
This PR makes the necessary changes to pass all checks. Including:
- Adding a licenseignore file
- Moving `swift-format` and adopting the config that we use in all other swift on server repos.
# Result
Green CI.