Skip to content

Commit a4a6e8d

Browse files
youknowoneSnowapril
authored andcommitted
Fix trivial suggestions
1 parent 4416b2a commit a4a6e8d

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

vm/src/builtins/float.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,7 @@ impl AsNumber for PyFloat {
554554
PyFloat::number_op(a, b, float_pow, vm)
555555
} else {
556556
Err(vm.new_type_error(String::from(
557-
"pow() 3rd argument not \\
558-
allowed unless all arguments are integers",
557+
"pow() 3rd argument not allowed unless all arguments are integers",
559558
)))
560559
}
561560
}),

vm/src/stdlib/builtins.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,10 +621,8 @@ mod builtins {
621621
exp: y,
622622
modulus,
623623
} = args;
624-
match modulus {
625-
None => vm._pow(&x, &y, vm.ctx.none.as_object()),
626-
Some(z) => vm._pow(&x, &y, &z),
627-
}
624+
let modulus = modulus.as_ref().map_or(vm.ctx.none.as_object(), |m| m);
625+
vm._pow(&x, &y, modulus)
628626
}
629627

630628
#[pyfunction]

vm/src/types/slot.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -567,28 +567,22 @@ impl PyType {
567567
}
568568
_ if name == identifier!(ctx, __pow__) => {
569569
toggle_subslot!(as_number, power, |a, b, c, vm| {
570-
if vm.is_none(c) {
571-
vm.call_special_method(a, identifier!(vm, __pow__), (b.to_owned(),))
570+
let args = if vm.is_none(c) {
571+
vec![b.to_owned()]
572572
} else {
573-
vm.call_special_method(
574-
a,
575-
identifier!(vm, __pow__),
576-
(b.to_owned(), c.to_owned()),
577-
)
578-
}
573+
vec![b.to_owned(), c.to_owned()]
574+
};
575+
vm.call_special_method(a, identifier!(vm, __pow__), args)
579576
});
580577
}
581578
_ if name == identifier!(ctx, __rpow__) => {
582579
toggle_subslot!(as_number, right_power, |a, b, c, vm| {
583-
if vm.is_none(c) {
584-
vm.call_special_method(b, identifier!(vm, __rpow__), (a.to_owned(),))
580+
let args = if vm.is_none(c) {
581+
vec![a.to_owned()]
585582
} else {
586-
vm.call_special_method(
587-
b,
588-
identifier!(vm, __rpow__),
589-
(a.to_owned(), c.to_owned()),
590-
)
591-
}
583+
vec![a.to_owned(), c.to_owned()]
584+
};
585+
vm.call_special_method(b, identifier!(vm, __rpow__), args)
592586
});
593587
}
594588
_ if name == identifier!(ctx, __ipow__) => {

0 commit comments

Comments
 (0)