MCPcopy Index your code
hub / github.com/RustPython/RustPython / int_add

Method int_add

crates/vm/src/frame.rs:7085–7093  ·  view source on GitHub ↗
(&self, a: &BigInt, b: &BigInt, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

7083 /// Int addition with i64 fast path to avoid BigInt heap allocation.
7084 #[inline]
7085 fn int_add(&self, a: &BigInt, b: &BigInt, vm: &VirtualMachine) -> PyObjectRef {
7086 use num_traits::ToPrimitive;
7087 if let (Some(av), Some(bv)) = (a.to_i64(), b.to_i64())
7088 && let Some(result) = av.checked_add(bv)
7089 {
7090 return vm.ctx.new_int(result).into();
7091 }
7092 vm.ctx.new_int(a + b).into()
7093 }
7094
7095 /// Int subtraction with i64 fast path to avoid BigInt heap allocation.
7096 #[inline]

Callers 1

execute_bin_opMethod · 0.80

Calls 1

new_intMethod · 0.45

Tested by

no test coverage detected