@@ 78,8 78,12 @@ pub fn Decoder(comptime ReaderType: type) type {
return x;
}
- if (@addWithOverflow(@TypeOf(s), s, 7, &s))
+ const ov = @addWithOverflow(s, 7);
+
+ if (0 != ov[1])
return DecodeError.Overflow;
+
+ s = ov[0];
}
return 0;
@@ 110,8 114,9 @@ pub fn Decoder(comptime ReaderType: type) type {
@compileError("structs must have 1 or more fields");
var s: T = undefined;
+
inline for (ti.fields) |f|
- @field(s, f.name) = try self.decode(f.field_type);
+ @field(s, f.name) = try self.decode(f.type);
return s;
}
@@ 135,9 140,8 @@ pub fn Decoder(comptime ReaderType: type) type {
@compileError("array length must be at least 1");
var buf: [ti.len]ti.child = undefined;
- var i: usize = 0;
- while (i < ti.len) : (i += 1)
+ for (0..ti.len) |i|
buf[i] = try self.decode(ti.child);
return buf;
@@ 153,7 157,7 @@ pub fn Decoder(comptime ReaderType: type) type {
inline for (ti.fields) |f| {
if (tag == @enumToInt(@field(ti.tag_type.?, f.name))) {
- const v = try self.decodeAllowVoid(f.field_type);
+ const v = try self.decodeAllowVoid(f.type);
return @unionInit(T, f.name, v);
}
}
@@ 390,7 394,7 @@ fn HashMapType(comptime T: type, comptime field_name: []const u8) type {
inline for (fields) |f|
if (comptime mem.eql(u8, f.name, field_name))
- return f.field_type;
+ return f.type;
}
fn isValidHashMapKeyType(comptime T: type) bool {
@@ 10,7 10,7 @@ pub fn main() !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = arena.allocator();
- const tp = try benchmarkRead(allocator, 1000000000);
+ const tp = try benchmarkRead(allocator, 10000000);
const stdout = std.io.getStdOut().writer();
try stdout.print("throughput: {}\n", .{tp});
}