authorgravatar for keitam913@yahoo.co.jpMizuochi Keita <keitam913@yahoo.co.jp> 2023-05-26 15:55:21+09:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-05-29 13:04:55+03:00
logec58b475b7ee913ff7ad0bf59bb2c71f0705e76e
treea0e32db53446bfbdbcb98fa4d002a381258b6722
parent4422af8be96d243db7840b840737069c38be8afb

std.math.big.int: Fix typo

- `bytes` -> `buffer` - Correct naming consistency between 1. fn argument and doc comment of `(read|write)PackedTwosComplement` 2. fn arguments of `(read|write)PackedTwosComplement` and `(read|write)TwosComplement`

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

lib/std/math/big/int.zig+9-9
......@@ -1890,7 +1890,7 @@ pub const Mutable = struct {
18901890 /// if it were a field in packed memory at the provided bit offset.
18911891 pub fn readPackedTwosComplement(
18921892 x: *Mutable,
1893 bytes: []const u8,
1893 buffer: []const u8,
18941894 bit_offset: usize,
18951895 bit_count: usize,
18961896 endian: Endian,
......@@ -1909,11 +1909,11 @@ pub const Mutable = struct {
19091909 const total_bits = bit_offset + bit_count;
19101910 var last_byte = switch (endian) {
19111911 .Little => ((total_bits + 7) / 8) - 1,
1912 .Big => bytes.len - ((total_bits + 7) / 8),
1912 .Big => buffer.len - ((total_bits + 7) / 8),
19131913 };
19141914
19151915 const sign_bit = @as(u8, 1) << @intCast(u3, (total_bits - 1) % 8);
1916 positive = ((bytes[last_byte] & sign_bit) == 0);
1916 positive = ((buffer[last_byte] & sign_bit) == 0);
19171917 }
19181918
19191919 // Copy all complete limbs
......@@ -1922,7 +1922,7 @@ pub const Mutable = struct {
19221922 var bit_index: usize = 0;
19231923 while (limb_index < bit_count / @bitSizeOf(Limb)) : (limb_index += 1) {
19241924 // Read one Limb of bits
1925 var limb = mem.readPackedInt(Limb, bytes, bit_index + bit_offset, endian);
1925 var limb = mem.readPackedInt(Limb, buffer, bit_index + bit_offset, endian);
19261926 bit_index += @bitSizeOf(Limb);
19271927
19281928 // 2's complement (bitwise not, then add carry bit)
......@@ -1938,10 +1938,10 @@ pub const Mutable = struct {
19381938 if (bit_count != bit_index) {
19391939 // Read all remaining bits
19401940 var limb = switch (signedness) {
1941 .unsigned => mem.readVarPackedInt(Limb, bytes, bit_index + bit_offset, bit_count - bit_index, endian, .unsigned),
1941 .unsigned => mem.readVarPackedInt(Limb, buffer, bit_index + bit_offset, bit_count - bit_index, endian, .unsigned),
19421942 .signed => b: {
19431943 const SLimb = std.meta.Int(.signed, @bitSizeOf(Limb));
1944 const limb = mem.readVarPackedInt(SLimb, bytes, bit_index + bit_offset, bit_count - bit_index, endian, .signed);
1944 const limb = mem.readVarPackedInt(SLimb, buffer, bit_index + bit_offset, bit_count - bit_index, endian, .signed);
19451945 break :b @bitCast(Limb, limb);
19461946 },
19471947 };
......@@ -2383,7 +2383,7 @@ pub const Const = struct {
23832383 ///
23842384 /// This is equivalent to storing the value of an integer with `bit_count` bits as
23852385 /// if it were a field in packed memory at the provided bit offset.
2386 pub fn writePackedTwosComplement(x: Const, bytes: []u8, bit_offset: usize, bit_count: usize, endian: Endian) void {
2386 pub fn writePackedTwosComplement(x: Const, buffer: []u8, bit_offset: usize, bit_count: usize, endian: Endian) void {
23872387 assert(x.fitsInTwosComp(if (x.positive) .unsigned else .signed, bit_count));
23882388
23892389 // Copy all complete limbs
......@@ -2401,7 +2401,7 @@ pub const Const = struct {
24012401 }
24022402
24032403 // Write one Limb of bits
2404 mem.writePackedInt(Limb, bytes, bit_index + bit_offset, limb, endian);
2404 mem.writePackedInt(Limb, buffer, bit_index + bit_offset, limb, endian);
24052405 bit_index += @bitSizeOf(Limb);
24062406 }
24072407
......@@ -2413,7 +2413,7 @@ pub const Const = struct {
24132413 if (!x.positive) limb = ~limb +% carry;
24142414
24152415 // Write all remaining bits
2416 mem.writeVarPackedInt(bytes, bit_index + bit_offset, bit_count - bit_index, limb, endian);
2416 mem.writeVarPackedInt(buffer, bit_index + bit_offset, bit_count - bit_index, limb, endian);
24172417 }
24182418 }
24192419