Skip to content

Commit

Permalink
simplify boolean condition
Browse files Browse the repository at this point in the history
  • Loading branch information
zarboq committed Nov 2, 2023
1 parent 29af1ca commit 1554e15
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
21 changes: 3 additions & 18 deletions src/oracle/oracle_utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,7 @@ fn revert_oracle_block_number_not_within_range(
/// # Returns
/// Wether it's the right error.
fn is_oracle_error(error_selector: felt252) -> bool {
if (is_oracle_block_number_error(error_selector)) {
return true;
}

if (is_empty_price_error(error_selector)) {
return true;
}

return false;
is_oracle_block_number_error(error_selector) || is_empty_price_error(error_selector)
}

/// Check wether `error` is an EmptyPriceError.
Expand All @@ -376,15 +368,8 @@ const BLOCK_NUMBERS_ARE_SMALLER_THAN_REQUIRED_SELECTOR: felt252 =
selector!("BLOCK_NUMBERS_ARE_SMALLER_THAN_REQUIRED");
const BLOCK_NUMBER_NOT_WITHIN_RANGE_SELECTOR: felt252 = selector!("BLOCK_NUMBER_NOT_WITHIN_RANGE");
fn is_oracle_block_number_error(error_selector: felt252) -> bool {
if (error_selector == BLOCK_NUMBERS_ARE_SMALLER_THAN_REQUIRED_SELECTOR) {
return true;
}

if (error_selector == BLOCK_NUMBER_NOT_WITHIN_RANGE_SELECTOR) {
return true;
}

return false;
error_selector == BLOCK_NUMBERS_ARE_SMALLER_THAN_REQUIRED_SELECTOR
|| error_selector == BLOCK_NUMBER_NOT_WITHIN_RANGE_SELECTOR
}

impl DefaultReportInfo of Default<ReportInfo> {
Expand Down
12 changes: 4 additions & 8 deletions src/utils/arrays.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,10 @@ fn are_lte(mut arr: Span<u128>, value: u128) -> bool {
fn are_lte_u64(mut arr: Span<u64>, value: u64) -> bool {
loop {
match arr.pop_front() {
Option::Some(item) => {
if *item > value {
break false;
}
},
Option::None => {
break true;
},
Option::Some(item) => { if *item > value {
break false;
} },
Option::None => { break true; },
};
}
}
Expand Down

0 comments on commit 1554e15

Please sign in to comment.