authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-12-19 17:48:21-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-12-19 17:48:21-05:00
log8768816d69ddf3253d2598923643f390cc18082c
tree8e2962aa68bacc59a0253a9d039759b20de639b0
parenta7670e80a49021fb96d1f9a1bbcbcfc6c1e835ab
signature Commit is signed but in an unrecognized format.

std.io: call the idiomatic std.mem.readInt functions

I originally called the Slice variants to work around comptime code not supporting `@ptrCast`, but I fixed that in 757d0665 so now the workaround is no longer needed.

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

std/io.zig+5-5
......@@ -155,32 +155,32 @@ pub fn InStream(comptime ReadError: type) type {
155155 pub fn readIntNative(self: *Self, comptime T: type) !T {
156156 var bytes: [@sizeOf(T)]u8 = undefined;
157157 try self.readNoEof(bytes[0..]);
158 return mem.readIntSliceNative(T, bytes);
158 return mem.readIntNative(T, &bytes);
159159 }
160160
161161 /// Reads a foreign-endian integer
162162 pub fn readIntForeign(self: *Self, comptime T: type) !T {
163163 var bytes: [@sizeOf(T)]u8 = undefined;
164164 try self.readNoEof(bytes[0..]);
165 return mem.readIntSliceForeign(T, bytes);
165 return mem.readIntForeign(T, &bytes);
166166 }
167167
168168 pub fn readIntLittle(self: *Self, comptime T: type) !T {
169169 var bytes: [@sizeOf(T)]u8 = undefined;
170170 try self.readNoEof(bytes[0..]);
171 return mem.readIntSliceLittle(T, bytes);
171 return mem.readIntLittle(T, &bytes);
172172 }
173173
174174 pub fn readIntBig(self: *Self, comptime T: type) !T {
175175 var bytes: [@sizeOf(T)]u8 = undefined;
176176 try self.readNoEof(bytes[0..]);
177 return mem.readIntSliceBig(T, bytes);
177 return mem.readIntBig(T, &bytes);
178178 }
179179
180180 pub fn readInt(self: *Self, comptime T: type, endian: builtin.Endian) !T {
181181 var bytes: [@sizeOf(T)]u8 = undefined;
182182 try self.readNoEof(bytes[0..]);
183 return mem.readIntSlice(T, bytes, endian);
183 return mem.readInt(T, &bytes, endian);
184184 }
185185
186186 pub fn readVarInt(self: *Self, comptime ReturnType: type, endian: builtin.Endian, size: usize) !ReturnType {