{"action":"created","issue":{"url":"https://api.github.com/repos/frewsxcv/tiny-http/issues/100","labels_url":"https://api.github.com/repos/frewsxcv/tiny-http/issues/100/labels{/name}","comments_url":"https://api.github.com/repos/frewsxcv/tiny-http/issues/100/comments","events_url":"https://api.github.com/repos/frewsxcv/tiny-http/issues/100/events","html_url":"https://github.com/frewsxcv/tiny-http/issues/100","id":101191567,"number":100,"title":"Headers as HashMap rather than Vec<Header>?","user":{"login":"bomattin","id":10439818,"avatar_url":"https://avatars.githubusercontent.com/u/10439818?v=3","gravatar_id":"","url":"https://api.github.com/users/bomattin","html_url":"https://github.com/bomattin","followers_url":"https://api.github.com/users/bomattin/followers","following_url":"https://api.github.com/users/bomattin/following{/other_user}","gists_url":"https://api.github.com/users/bomattin/gists{/gist_id}","starred_url":"https://api.github.com/users/bomattin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bomattin/subscriptions","organizations_url":"https://api.github.com/users/bomattin/orgs","repos_url":"https://api.github.com/users/bomattin/repos","events_url":"https://api.github.com/users/bomattin/events{/privacy}","received_events_url":"https://api.github.com/users/bomattin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-15T17:29:33Z","updated_at":"2015-08-15T17:52:56Z","closed_at":null,"body":"Might it make more sense to implement Headers as a `std::collections::HashMap` rather than a Vec of `Header`s? Since HTTP headers are always key-value pairs, and often we want to do lookups on them (see, for example, [this iteration](https://github.com/frewsxcv/tiny-http/blob/master/src/request.rs#L125-L127), it seems to me a HashMap of Strings might ultimately be a better choice. The pros and cons that stand out to me are below:\r\n\r\n### Pros\r\n+ Faster lookup\r\n+ Potential feature expansion\r\n\r\n### Cons\r\n- Refactor of an existing and working feature\r\n- Lose control over header format without additional refactor on functions that build Headers"},"comment":{"url":"https://api.github.com/repos/frewsxcv/tiny-http/issues/comments/131409981","html_url":"https://github.com/frewsxcv/tiny-http/issues/100#issuecomment-131409981","issue_url":"https://api.github.com/repos/frewsxcv/tiny-http/issues/100","id":131409981,"user":{"login":"tomaka","id":1412254,"avatar_url":"https://avatars.githubusercontent.com/u/1412254?v=3","gravatar_id":"","url":"https://api.github.com/users/tomaka","html_url":"https://github.com/tomaka","followers_url":"https://api.github.com/users/tomaka/followers","following_url":"https://api.github.com/users/tomaka/following{/other_user}","gists_url":"https://api.github.com/users/tomaka/gists{/gist_id}","starred_url":"https://api.github.com/users/tomaka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomaka/subscriptions","organizations_url":"https://api.github.com/users/tomaka/orgs","repos_url":"https://api.github.com/users/tomaka/repos","events_url":"https://api.github.com/users/tomaka/events{/privacy}","received_events_url":"https://api.github.com/users/tomaka/received_events","type":"User","site_admin":false},"created_at":"2015-08-15T17:52:56Z","updated_at":"2015-08-15T17:52:56Z","body":"Is the lookup really faster?\r\n\r\nWith a Vec, the code likely compares the first few letters of each string until it finds the correct one. With a HashMap, you need to build a hash of the string, and with the default SipHasher it can take much longer than expected.\r\n\r\nOf course if there were a lot of headers the HashMap would win, but requests and responses usually have a maximum 15-20 headers.\r\n"}}