Fix unnecessary computation (#5055)

This commit is contained in:
Sagar Dhawan 2019-07-12 11:30:37 -07:00 committed by GitHub
parent f093377805
commit 7c12ecbe81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions

View File

@ -78,13 +78,11 @@ pub fn get_complete_segment_from_slot(
rooted_slot: Slot, rooted_slot: Slot,
slots_per_segment: u64, slots_per_segment: u64,
) -> Option<Segment> { ) -> Option<Segment> {
let current_segment = get_segment_from_slot(rooted_slot, slots_per_segment); let completed_segment = rooted_slot / slots_per_segment;
if current_segment == 1 { if rooted_slot < slots_per_segment {
None None
} else if rooted_slot < (current_segment * slots_per_segment) {
Some(current_segment - 1)
} else { } else {
Some(current_segment) Some(completed_segment)
} }
} }