32 Commits
Author SHA1 Message Date
Mathias Quintero 6c8ca82973 Improve allocations in Large Field Equality Checks (#150)
### 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.
2026-09-03 15:00:23 +00:00
Hashim Khan dfebed0b4e Make HTTPFields hashing consistent with equality (#143)
## 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
2026-09-03 13:55:14 +00:00
Fabian Fett 6aff14dae9 Add inlinables (#149)
### 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
2026-09-01 16:09:13 +02:00
Fabian Fett e186752bbc Improve equality check performance (#141)
### 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
2026-08-18 14:46:30 +00:00
Fabian Fett 43cf84fb56 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
2026-08-18 14:26:31 +02:00
Fabian Fett 37b3778072 Stop copying the name index dictionary on every HTTPFields.append (#134)
### 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.
2026-08-12 16:28:16 +02:00
Guoye Zhang 141600d7e6 Adopt availability macros (#127) 2026-06-22 15:16:29 -07:00
Guoye Zhang db774a277f Support embedded Swift (#116)
In order for swift-http-api-proposal to support embedded Swift,
swift-http-types has to support embedded Swift first.
2026-06-05 10:54:44 -07:00
Rick Newton-RogersandGuoye Zhang c98018204b Drop Swift 6.0 (#114)
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>
2026-04-01 21:51:13 +01:00
Guoye Zhang 32a95f29c1 Check the compiler version instead 2024-10-28 18:34:49 -07:00
Guoye Zhang c82e4078cd Adopt Mutex where available 2024-10-28 14:26:36 -07:00
Franz Busch f3d9ec3eef [CI] Make all CI checks green
# 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.
2024-10-24 22:30:18 +02:00
Guoye Zhang 6b3c3a26b7 Adopt NIOLock 2024-10-23 11:26:17 -07:00
Guoye Zhang 7c0a607f38 Merge pull request #49 from simonjbeaumont/sb/musl-support
Support compiling against Musl
2024-05-09 02:20:16 -07:00
Si Beaumont 146ca95fbb Support compiling against Musl libc 2024-05-08 13:26:10 +01:00
Joannis Orlandos dfefea8004 Reserve capacity before appending elements during initialization through dictionary literal 2024-02-01 00:32:19 +01:00
Max Desiatov a114507558 Fix building for WASI 2024-01-11 17:16:25 +00:00
Guoye Zhang fee4574296 Revert argument changes 2023-12-02 13:03:51 -08:00
Gwynne Raskind 28a5f3aaeb Per PR discussion, remove platform specifiers and discontinue use of some rather than forcing other packages to change their manifests. 2023-12-02 00:50:23 -06:00
Guoye Zhang b4af788d7e Merge pull request #33 from guoye-zhang/fields-sequence
Eliminate the allocation of single element arrays
2023-11-16 23:34:38 -08:00
Guoye Zhang e716d5d2bc Values -> fields 2023-11-15 16:56:35 -08:00
Guoye Zhang 165e7ecdd3 Remove @_implementationOnly 2023-11-14 18:31:27 -08:00
Guoye Zhang 2d2eb2942b Eliminate the allocation of single element arrays 2023-11-14 16:50:46 -08:00
Guoye Zhang 4105126730 Rename raw subscript to values 2023-09-02 12:48:20 -07:00
Guoye Zhang e6f8a18b0e Keep track of both the first and last index of a field name 2023-08-17 17:33:38 -07:00
Guoye Zhang bd06898009 Merge pull request #23 from guoye-zhang/codable
Support Codable
2023-08-17 15:37:47 -07:00
Guoye Zhang e885fa315c Remove custom DecodingError and harden fields 2023-08-08 13:39:37 -07:00
Guoye Zhang 792abeab1f Support Codable 2023-08-07 18:09:53 -07:00
Guoye Zhang 4c7d1331a5 Field order should be insignificant between fields of different names 2023-08-07 16:14:56 -07:00
Guoye Zhang f610691a14 Code formatting fixes
Adding additional self. missed by SwiftFormat
2023-07-12 16:44:56 -07:00
Guoye Zhang ae848811f9 Internal API review feedback 2023-06-30 10:06:35 -07:00
Guoye Zhang c164739694 Import code 2023-06-30 10:06:35 -07:00