mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 04:49:06 +00:00
Address review feedback
- Remove unnecessary @truncate for i32->i32 conversions - Remove unnecessary @as(usize) cast for result.items.len - Use @intCast where maxInt checks ensure safe conversion - Revert skip function change that didn't add value 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -418,7 +418,7 @@ fn parseArray(bytes: []const u8, bigint: bool, comptime arrayType: types.Tag, gl
|
||||
else => {
|
||||
const value = std.fmt.parseInt(i32, element, 0) catch return error.UnsupportedArrayFormat;
|
||||
|
||||
try array.append(bun.default_allocator, SQLDataCell{ .tag = .int4, .value = .{ .int4 = @truncate(value) } });
|
||||
try array.append(bun.default_allocator, SQLDataCell{ .tag = .int4, .value = .{ .int4 = value } });
|
||||
slice = trySlice(slice, current_idx);
|
||||
continue;
|
||||
},
|
||||
@@ -776,7 +776,7 @@ fn parseBinaryNumeric(input: []const u8, result: *std.ArrayList(u8)) !PGNummeric
|
||||
// negative scale means we need to add zeros before the decimal point
|
||||
// greater than ndigits means we need to add zeros after the decimal point
|
||||
var idx: isize = scale_start;
|
||||
const end: usize = @as(usize, result.items.len) + @as(usize, @max(dscale, 0));
|
||||
const end: usize = result.items.len + @as(usize, @max(dscale, 0));
|
||||
while (idx < dscale) : (idx += 4) {
|
||||
if (idx >= 0 and idx < ndigits) {
|
||||
const digit = reader.readInt(u16, .big) catch 0;
|
||||
@@ -911,7 +911,7 @@ pub const Putter = struct {
|
||||
if (is_raw) {
|
||||
cell.* = SQLDataCell.raw(optional_bytes);
|
||||
} else {
|
||||
const tag = if (std.math.maxInt(short) < oid) .text else @as(types.Tag, @enumFromInt(@as(short, @truncate(oid))));
|
||||
const tag = if (std.math.maxInt(short) < oid) .text else @as(types.Tag, @enumFromInt(@as(short, @intCast(oid))));
|
||||
cell.* = if (optional_bytes) |data|
|
||||
try fromBytes((field.binary or this.binary) and tag.isBinaryFormatSupported(), this.bigint, tag, data.slice(), this.globalObject)
|
||||
else
|
||||
@@ -927,7 +927,7 @@ pub const Putter = struct {
|
||||
// The indexed columns can be out of order.
|
||||
.index => |i| i,
|
||||
|
||||
else => @truncate(index),
|
||||
else => index,
|
||||
};
|
||||
|
||||
// TODO: when duplicate and we know the result will be an object
|
||||
|
||||
@@ -29,7 +29,7 @@ pub fn writeBind(
|
||||
for (0..len) |i| {
|
||||
const parameter_field = parameter_fields[i];
|
||||
const is_custom_type = std.math.maxInt(short) < parameter_field;
|
||||
const tag: types.Tag = if (is_custom_type) .text else @enumFromInt(@as(short, @truncate(parameter_field)));
|
||||
const tag: types.Tag = if (is_custom_type) .text else @enumFromInt(@as(short, @intCast(parameter_field)));
|
||||
|
||||
const force_text = is_custom_type or (tag.isBinaryFormatSupported() and brk: {
|
||||
iter.to(@truncate(i));
|
||||
@@ -78,7 +78,7 @@ pub fn writeBind(
|
||||
}
|
||||
const parameter_field = parameter_fields[i];
|
||||
const is_custom_type = std.math.maxInt(short) < parameter_field;
|
||||
break :brk if (is_custom_type) .text else @enumFromInt(@as(short, @truncate(parameter_field)));
|
||||
break :brk if (is_custom_type) .text else @enumFromInt(@as(short, @intCast(parameter_field)));
|
||||
};
|
||||
if (value.isEmptyOrUndefinedOrNull()) {
|
||||
debug(" -> NULL", .{});
|
||||
@@ -316,7 +316,7 @@ pub fn onData(
|
||||
debug("Unknown message: {c}", .{c});
|
||||
const to_skip = try reader.length() -| 1;
|
||||
debug("to_skip: {d}", .{to_skip});
|
||||
try reader.skip(@as(usize, @max(to_skip, 0)));
|
||||
try reader.skip(@intCast(@max(to_skip, 0)));
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user