| ... | ... | @@ -102,9 +102,19 @@ test "HeaderEntry" { |
| 102 | 102 | testing.expectEqualSlices(u8, "x", e.value); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | fn stringEql(a: []const u8, b: []const u8) bool { |
| 106 | if (a.len != b.len) return false; |
| 107 | if (a.ptr == b.ptr) return true; |
| 108 | return mem.compare(u8, a, b) == .Equal; |
| 109 | } |
| 110 | |
| 111 | fn stringHash(s: []const u8) u32 { |
| 112 | return @truncate(u32, std.hash.wyhash(s, 0)); |
| 113 | } |
| 114 | |
| 105 | 115 | const HeaderList = std.ArrayList(HeaderEntry); |
| 106 | 116 | const HeaderIndexList = std.ArrayList(usize); |
| 107 | | const HeaderIndex = std.AutoHashMap([]const u8, HeaderIndexList); |
| 117 | const HeaderIndex = std.HashMap([]const u8, HeaderIndexList, stringHash, stringEql); |
| 108 | 118 | |
| 109 | 119 | pub const Headers = struct { |
| 110 | 120 | // the owned header field name is stored in the index as part of the key |