16 Commits
Author SHA1 Message Date
tomer doron dd9aca3533 fix formatting so that sanity script passes (#7)
* fix formatting so that sanity script passes

motivation: consistent formatting as prep for OSS

changes: run swiftformat to align formatting

* dont use TSAN on 18.04
2021-01-15 08:11:21 +00:00
Cory Benfield b2ea94c173 Remove unnecessary genericism and generic constraints.
Motivation:

Early on in the design of Structured Headers I made a conscious effort
to try to avoid transforming types in the low-level API. This design was
built on the assumption that strings, tokens, and some other data types
could be built entirely as slices of the backing data.

Unfortunately, this isn't true: because of the need to escape chars in
Strings, it became necessary to start using more complex types in Item.
Eventually, we ended up in a place where the only field in Item that
actually stored backing data was `.undecodedByteSequence`.

This field forced almost the entire set of types in the
StructuredHeaders module to be generic, just for the sake of carrying
this one slice type around. This prevented powerful optimisations,
bloated code size, and forced additional unnecessary heap allocations.
It also forced us to constrain the types used in the parser to those
where the subsequence type was Hashable, which excluded some really
important types (like `String.UTF8View`).

Fundamentally, this genericism was hurting more than it helped at this
point, so I bit the bullet and replaced the slice type with `String` for
`undecodedByteSequence`. This led to a huge cascading removal of generic
type parameters for a wide range of types, as well as the removal of the
"must have hashable subsequence" constraints on the parser data type.
This lifts an enormous amount of complexity out of the module at the
extremely minor cost of forcing an allocation whenever we have a lot of
undecoded binary data: not a huge cost, in my view, and well worth what
we got back in return.

Modifications:

- Remove generic type parameter in BaseItem.
- Remove generic types everywhere else.
- Remove hashable constraint.

Result:

Better, faster, simpler code.
2020-08-28 16:42:42 +01:00
Cory Benfield 6a2b13e370 Fix the build on Linux
Motivation:

A number of the changes in the code for running on Linux
were not validated ahead of time, and broke the build.

Modifications:

- Correct the spelling of Glibc
- Modified string initialization on non-Darwin platforms

Results:

Builds and passes tests on Linux
2020-07-20 12:44:21 +01:00
Cory Benfield 3f73125a0d Apply formatting 2020-07-17 10:06:44 +01:00
Cory Benfield e12def54da Add docs and license 2020-07-16 16:34:38 +01:00
Cory Benfield 5aaca631da Split Codable to its own module 2020-07-16 11:22:30 +01:00
Cory Benfield 8cd792800c Remove foundation from core 2020-07-16 10:55:55 +01:00
Cory Benfield ea7969a4c6 Support Encoder 2020-07-15 16:20:26 +01:00
Cory Benfield 882cb88c87 Make dictionary/parameter keys strings too 2020-07-10 14:11:36 +01:00
Cory Benfield f07f69282d Make tokens strings (it's easier) 2020-07-10 13:49:05 +01:00
Cory Benfield cf08d29cb0 Implement the Serializer. 2020-07-09 14:53:15 +01:00
Cory Benfield e6e0c68caf Additional testing 2020-07-05 17:11:02 +01:00
Cory Benfield 49370cd8db Initial basic Decoder implementation 2020-07-05 13:21:16 +01:00
Cory Benfield 68a2409ef9 Remove duplicate character checks 2020-07-01 17:01:07 +01:00
Cory Benfield 03fa905bed Initial Structured Headers decoder. 2020-07-01 16:41:52 +01:00
Cory Benfield fa8c1e771c Initial commit 2020-06-19 17:17:12 +01:00