diff options
| author | Hiroaki Nakamura <hnakamur@gmail.com> | 2022-07-16 11:46:13 +0900 |
|---|---|---|
| committer | Hiroaki Nakamura <hnakamur@gmail.com> | 2022-07-16 11:46:13 +0900 |
| commit | 3e667fd2925274c674bddfd2d3f67f6edd1bf72b (patch) | |
| tree | ddb8453bd5e09089438fec6f31055d7ecb188f05 /lib/std/math | |
| parent | 0cee8372cfe31e58eaa66621ac4d2039d4600ce9 (diff) | |
| download | zig-3e667fd2925274c674bddfd2d3f67f6edd1bf72b.tar.gz zig-3e667fd2925274c674bddfd2d3f67f6edd1bf72b.zip | |
Use Managed.len in sub, divFloor, and divTrunc too
Diffstat (limited to 'lib/std/math')
| -rw-r--r-- | lib/std/math/big/int.zig | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig index cf6dad23b6..2a141ac243 100644 --- a/lib/std/math/big/int.zig +++ b/lib/std/math/big/int.zig @@ -2719,7 +2719,7 @@ pub const Managed = struct { /// /// Returns an error if memory could not be allocated. pub fn sub(r: *Managed, a: *const Managed, b: *const Managed) !void { - try r.ensureCapacity(math.max(a.limbs.len, b.limbs.len) + 1); + try r.ensureCapacity(math.max(a.len(), b.len()) + 1); var m = r.toMutable(); m.sub(a.toConst(), b.toConst()); r.setMetadata(m.positive, m.len); @@ -2813,7 +2813,7 @@ pub const Managed = struct { if (alias_count == 0) { m.mulWrapNoAlias(a.toConst(), b.toConst(), signedness, bit_count, rma.allocator); } else { - const limb_count = calcMulWrapLimbsBufferLen(bit_count, a.limbs.len, b.limbs.len, alias_count); + const limb_count = calcMulWrapLimbsBufferLen(bit_count, a.len(), b.len(), alias_count); const limbs_buffer = try rma.allocator.alloc(Limb, limb_count); defer rma.allocator.free(limbs_buffer); m.mulWrap(a.toConst(), b.toConst(), signedness, bit_count, limbs_buffer, rma.allocator); @@ -2843,11 +2843,11 @@ pub const Managed = struct { /// /// Returns an error if memory could not be allocated. pub fn divFloor(q: *Managed, r: *Managed, a: *const Managed, b: *const Managed) !void { - try q.ensureCapacity(a.limbs.len); - try r.ensureCapacity(b.limbs.len); + try q.ensureCapacity(a.len()); + try r.ensureCapacity(b.len()); var mq = q.toMutable(); var mr = r.toMutable(); - const limbs_buffer = try q.allocator.alloc(Limb, calcDivLimbsBufferLen(a.limbs.len, b.limbs.len)); + const limbs_buffer = try q.allocator.alloc(Limb, calcDivLimbsBufferLen(a.len(), b.len())); defer q.allocator.free(limbs_buffer); mq.divFloor(&mr, a.toConst(), b.toConst(), limbs_buffer); q.setMetadata(mq.positive, mq.len); @@ -2860,11 +2860,11 @@ pub const Managed = struct { /// /// Returns an error if memory could not be allocated. pub fn divTrunc(q: *Managed, r: *Managed, a: *const Managed, b: *const Managed) !void { - try q.ensureCapacity(a.limbs.len); - try r.ensureCapacity(b.limbs.len); + try q.ensureCapacity(a.len()); + try r.ensureCapacity(b.len()); var mq = q.toMutable(); var mr = r.toMutable(); - const limbs_buffer = try q.allocator.alloc(Limb, calcDivLimbsBufferLen(a.limbs.len, b.limbs.len)); + const limbs_buffer = try q.allocator.alloc(Limb, calcDivLimbsBufferLen(a.len(), b.len())); defer q.allocator.free(limbs_buffer); mq.divTrunc(&mr, a.toConst(), b.toConst(), limbs_buffer); q.setMetadata(mq.positive, mq.len); |
