mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-24 04:38:00 +00:00
Motivation: The canonicalForm subscript was written for clarity, but it didn't do a good job of avoiding performance costs. Unfortunately, this function can be a bit costly, for two reasons. Firstly, it used a bunch of eager collection operations, such that it would allocate intermediate arrays. Secondly, it computed on the String, rather than the UTF8View backing that string, in order to perform those collection operations. The result was that it spent a bit too much time messing about with the headers than it needed to. Modifications: - Define a lazy UTF8 view splitting sequence and use it. - Change to compute on the UTF8View. Result: Better performance in the canonicalForm subscript.