authorgravatar for sahnvour@pm.meSahnvour <sahnvour@pm.me> 2019-09-03 23:56:04+02:00
committergravatar for sahnvour@pm.meSahnvour <sahnvour@pm.me> 2019-09-03 23:56:04+02:00
log9d6f236728cf433b44048e21f81efdd167fe0098
treeb2c159f7032e470aa4cdaf9b24f096a8defd0dc2
parentf08c6e4fe6ad63145ef69377f36f34e9f04cadec

add fastpath for std.mem.eql and simplify std.hash_map.eqlString

this should also be friendlier to the optimizer

2 files changed, 2 insertions(+), 3 deletions(-)

std/hash_map.zig+1-3
......@@ -23,9 +23,7 @@ pub fn StringHashMap(comptime V: type) type {
2323}
2424
2525pub fn eqlString(a: []const u8, b: []const u8) bool {
26 if (a.len != b.len) return false;
27 if (a.ptr == b.ptr) return true;
28 return mem.compare(u8, a, b) == .Equal;
26 return mem.eql(u8, a, b);
2927}
3028
3129pub fn hashString(s: []const u8) u32 {
std/mem.zig+1
......@@ -339,6 +339,7 @@ test "mem.lessThan" {
339339/// Compares two slices and returns whether they are equal.
340340pub fn eql(comptime T: type, a: []const T, b: []const T) bool {
341341 if (a.len != b.len) return false;
342 if (a.ptr == b.ptr) return true;
342343 for (a) |item, index| {
343344 if (b[index] != item) return false;
344345 }