-
Notifications
You must be signed in to change notification settings - Fork 626
feat(byte_array): add at
and index
to ByteSpan
#8427
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
base: gilad/09-14-feat_byte_array_add_slice_
Are you sure you want to change the base?
feat(byte_array): add at
and index
to ByteSpan
#8427
Conversation
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
f840c46
to
bcf3c7d
Compare
d2487b7
to
235db8b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TomerStarkware reviewed 2 of 2 files at r2, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @orizi)
235db8b
to
eeaa0bf
Compare
bcf3c7d
to
04b763d
Compare
04b763d
to
c03411e
Compare
45abe52
to
afd7694
Compare
8885cbb
to
a4243a8
Compare
9ab073e
to
b38e4cc
Compare
a4243a8
to
6769953
Compare
b38e4cc
to
20ea89a
Compare
6769953
to
19ce8b6
Compare
20ea89a
to
bc5dfbf
Compare
19ce8b6
to
4bf4932
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@orizi reviewed all commit messages.
Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @TomerStarkware)
corelib/src/byte_array.cairo
line 703 at r4 (raw file):
fn at(self: @ByteSpan, index: usize) -> Option<u8> { let actual_index = index.checked_add(upcast(self.first_char_start_offset))?; let (word_index, index_in_word) = DivRem::div_rem(actual_index, BYTES_IN_BYTES31_NONZERO);
use bounded_int::div_rem
and get index_in_word
in [0,30]
range.
you can use bounded_int::constrain
later to decide if it is accessing the lower or upper word.
Code quote:
let (word_index, index_in_word) = DivRem::div_rem(actual_index, BYTES_IN_BYTES31_NONZERO);
corelib/src/byte_array.cairo
line 713 at r4 (raw file):
if word_index == self.data.len() && index_in_word < upcast(self.remainder_len) { // index_in_word is from MSB, we need index from LSB. let index_in_remainder = upcast(self.remainder_len) - 1 - index_in_word;
bounded_int::sub as well.
Code quote:
let index_in_remainder = upcast(self.remainder_len) - 1 - index_in_word;
bc5dfbf
to
50fdc8e
Compare
acb4ec9
to
a82ef26
Compare
50fdc8e
to
079403d
Compare
a82ef26
to
4e56cca
Compare
079403d
to
04b050b
Compare
4e56cca
to
3a99931
Compare
04b050b
to
7331124
Compare
3a99931
to
d0a7c5c
Compare
7331124
to
cfb20a9
Compare
d0a7c5c
to
a98d3f8
Compare
cfb20a9
to
471439b
Compare
a98d3f8
to
62bd737
Compare
471439b
to
5b966b7
Compare
62bd737
to
696e439
Compare
5b966b7
to
f03f22e
Compare
696e439
to
bcf2452
Compare
f03f22e
to
4ffc000
Compare
bcf2452
to
627140e
Compare
4ffc000
to
5faa3d7
Compare
No description provided.