Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Cairo 2.5.3 and other refactors #271

Merged
merged 25 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
scarb 2.4.0
scarb 2.5.3
2 changes: 1 addition & 1 deletion Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ description = "Community maintained Cairo and Starknet libraries"
homepage = "https://github.com/keep-starknet-strange/alexandria/"

[workspace.dependencies]
starknet = ">=2.4.0"
starknet = ">=2.5.0"
delaaxe marked this conversation as resolved.
Show resolved Hide resolved

[workspace.tool.fmt]
sort-module-level-items = true
Expand Down
18 changes: 5 additions & 13 deletions src/ascii/src/integer.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ impl ToAsciiArrayTraitImpl<
}

let mut num = self;
loop {
if num.is_zero() {
break;
}
while num.is_non_zero() {
let (quotient, remainder) = DivRem::div_rem(
num, TryInto::<felt252, T>::try_into(10).unwrap().try_into().expect('Division by 0')
);
Expand Down Expand Up @@ -71,11 +68,9 @@ impl SmallIntegerToAsciiTraitImpl<

let mut inverse_ascii_arr = self.to_inverse_ascii_array().span();
let mut ascii: felt252 = 0;
loop {
match inverse_ascii_arr.pop_back() {
Option::Some(val) => { ascii = ascii * 256 + *val; },
Option::None(_) => { break; },
};
while !inverse_ascii_arr.is_empty() {
let val = *inverse_ascii_arr.pop_back().unwrap();
ascii = ascii * 256 + val;
delaaxe marked this conversation as resolved.
Show resolved Hide resolved
};

ascii
Expand Down Expand Up @@ -153,10 +148,7 @@ impl U256ToAsciiArrayTraitImpl of ToAsciiArrayTrait<u256> {
return new_arr;
}
let mut num = self;
loop {
if num.is_zero() {
break;
}
while num != 0 {
let (quotient, remainder) = DivRem::div_rem(
num, 10_u256.try_into().expect('Division by 0')
);
Expand Down
Loading
Loading