Skip to content

Commit 8768816

Browse files
committed
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 757d066 so now the workaround is no longer needed.
1 parent a7670e8 commit 8768816

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

std/io.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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 {

0 commit comments

Comments
 (0)