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 {...@@ -1890,7 +1890,7 @@ pub const Mutable = struct {
1890 /// if it were a field in packed memory at the provided bit offset.1890 /// if it were a field in packed memory at the provided bit offset.
1891 pub fn readPackedTwosComplement(1891 pub fn readPackedTwosComplement(
1892 x: *Mutable,1892 x: *Mutable,
1893 bytes: []const u8,1893 buffer: []const u8,
1894 bit_offset: usize,1894 bit_offset: usize,
1895 bit_count: usize,1895 bit_count: usize,
1896 endian: Endian,1896 endian: Endian,
...@@ -1909,11 +1909,11 @@ pub const Mutable = struct {...@@ -1909,11 +1909,11 @@ pub const Mutable = struct {
1909 const total_bits = bit_offset + bit_count;1909 const total_bits = bit_offset + bit_count;
1910 var last_byte = switch (endian) {1910 var last_byte = switch (endian) {
1911 .Little => ((total_bits + 7) / 8) - 1,1911 .Little => ((total_bits + 7) / 8) - 1,
1912 .Big => bytes.len - ((total_bits + 7) / 8),1912 .Big => buffer.len - ((total_bits + 7) / 8),
1913 };1913 };
19141914
1915 const sign_bit = @as(u8, 1) << @intCast(u3, (total_bits - 1) % 8);1915 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);
1917 }1917 }
19181918
1919 // Copy all complete limbs1919 // Copy all complete limbs
...@@ -1922,7 +1922,7 @@ pub const Mutable = struct {...@@ -1922,7 +1922,7 @@ pub const Mutable = struct {
1922 var bit_index: usize = 0;1922 var bit_index: usize = 0;
1923 while (limb_index < bit_count / @bitSizeOf(Limb)) : (limb_index += 1) {1923 while (limb_index < bit_count / @bitSizeOf(Limb)) : (limb_index += 1) {
1924 // Read one Limb of bits1924 // 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);
1926 bit_index += @bitSizeOf(Limb);1926 bit_index += @bitSizeOf(Limb);
19271927
1928 // 2's complement (bitwise not, then add carry bit)1928 // 2's complement (bitwise not, then add carry bit)
...@@ -1938,10 +1938,10 @@ pub const Mutable = struct {...@@ -1938,10 +1938,10 @@ pub const Mutable = struct {
1938 if (bit_count != bit_index) {1938 if (bit_count != bit_index) {
1939 // Read all remaining bits1939 // Read all remaining bits
1940 var limb = switch (signedness) {1940 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),
1942 .signed => b: {1942 .signed => b: {
1943 const SLimb = std.meta.Int(.signed, @bitSizeOf(Limb));1943 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);
1945 break :b @bitCast(Limb, limb);1945 break :b @bitCast(Limb, limb);
1946 },1946 },
1947 };1947 };
...@@ -2383,7 +2383,7 @@ pub const Const = struct {...@@ -2383,7 +2383,7 @@ pub const Const = struct {
2383 ///2383 ///
2384 /// This is equivalent to storing the value of an integer with `bit_count` bits as2384 /// This is equivalent to storing the value of an integer with `bit_count` bits as
2385 /// if it were a field in packed memory at the provided bit offset.2385 /// 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 {
2387 assert(x.fitsInTwosComp(if (x.positive) .unsigned else .signed, bit_count));2387 assert(x.fitsInTwosComp(if (x.positive) .unsigned else .signed, bit_count));
23882388
2389 // Copy all complete limbs2389 // Copy all complete limbs
...@@ -2401,7 +2401,7 @@ pub const Const = struct {...@@ -2401,7 +2401,7 @@ pub const Const = struct {
2401 }2401 }
24022402
2403 // Write one Limb of bits2403 // 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);
2405 bit_index += @bitSizeOf(Limb);2405 bit_index += @bitSizeOf(Limb);
2406 }2406 }
24072407
...@@ -2413,7 +2413,7 @@ pub const Const = struct {...@@ -2413,7 +2413,7 @@ pub const Const = struct {
2413 if (!x.positive) limb = ~limb +% carry;2413 if (!x.positive) limb = ~limb +% carry;
24142414
2415 // Write all remaining bits2415 // 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);
2417 }2417 }
2418 }2418 }
24192419