[swift-server-dev] Convert HTTPVersion to struct

Michael Chiu hatsuneyuji at icloud.com
Wed Jun 14 05:14:35 CDT 2017


I’m thinking that maybe It will be better to make both major/minor Int16/UInt16 instead, since the value we get from the http parser is an unsigned short, and making it a short help write the hash as the following without worrying about overflow due to bad programming from user. 

var hashValue: Int { return Int(major) << 16 &+ Int(minor) } 

may be a bit over engineering. Just a thought

Michael.

> On Jun 13, 2017, at 1:44 PM, Chris Bailey via swift-server-dev <swift-server-dev at swift.org> wrote:
> 
> Based on our discussed approach of reviewing each of the types in the HTTP project, I've raised the following PR to convert HTTPVersion from (Int, Int) to a struct based on Paulo's proposal: 
>         https://github.com/swift-server/http/pull/6 <https://github.com/swift-server/http/pull/6> 
> 
> I've not yet added Hashable, Equatable and CustomStringConvertible protocols - we can do that if we're happy with the change. 
> 
> Chris
> Unless stated otherwise above:
> IBM United Kingdom Limited - Registered in England and Wales with number 741598. 
> Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
> _______________________________________________
> swift-server-dev mailing list
> swift-server-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-server-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-server-dev/attachments/20170614/f8fa3b6a/attachment.html>


More information about the swift-server-dev mailing list