authorgravatar for cbilz@posteo.netConstantin Bilz <cbilz@posteo.net> 2023-10-19 12:42:44+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-10-20 19:06:32+03:00
log45d7dfa8333880ffa0a318723d22a0072bd32b3f
treefd00c3dae6731d08dbc01608746360b580511ba2
parent1631dc923d48d8c586e57f793adcdfb97760ceb3

std.hash_map: add `const` attribute to StringIndexContext.bytes and ...

StringIndexAdapter.bytes Without this change, constructing a Context/Adapter for a `const` string table requires a `@constCast`.

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

lib/std/hash_map.zig+2-2
...@@ -92,7 +92,7 @@ pub fn hashString(s: []const u8) u64 {...@@ -92,7 +92,7 @@ pub fn hashString(s: []const u8) u64 {
92}92}
9393
94pub const StringIndexContext = struct {94pub const StringIndexContext = struct {
95 bytes: *std.ArrayListUnmanaged(u8),95 bytes: *const std.ArrayListUnmanaged(u8),
9696
97 pub fn eql(self: @This(), a: u32, b: u32) bool {97 pub fn eql(self: @This(), a: u32, b: u32) bool {
98 _ = self;98 _ = self;
...@@ -106,7 +106,7 @@ pub const StringIndexContext = struct {...@@ -106,7 +106,7 @@ pub const StringIndexContext = struct {
106};106};
107107
108pub const StringIndexAdapter = struct {108pub const StringIndexAdapter = struct {
109 bytes: *std.ArrayListUnmanaged(u8),109 bytes: *const std.ArrayListUnmanaged(u8),
110110
111 pub fn eql(self: @This(), a_slice: []const u8, b: u32) bool {111 pub fn eql(self: @This(), a_slice: []const u8, b: u32) bool {
112 const b_slice = mem.sliceTo(@as([*:0]const u8, @ptrCast(self.bytes.items.ptr)) + b, 0);112 const b_slice = mem.sliceTo(@as([*:0]const u8, @ptrCast(self.bytes.items.ptr)) + b, 0);