Skip to content

Commit 36efb50

Browse files
committed
Refactor for less allocations
1 parent 6ba7655 commit 36efb50

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

vm/src/obj/objrange.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ impl PyRange {
8282
return None;
8383
}
8484

85-
let length = if start < stop {
85+
let length: BigInt = if start < stop {
8686
(stop - start - 1) / step + 1
8787
} else {
8888
(start - stop - 1) / (-step) + 1
8989
};
9090

91-
let index = if index < BigInt::zero() {
92-
let new_index = &length + &index;
93-
if new_index < BigInt::zero() {
91+
let index = if index.is_negative() {
92+
let new_index: BigInt = &length + &index;
93+
if new_index.is_negative() {
9494
return None;
9595
}
9696
length + index

0 commit comments

Comments
 (0)