Skip to content

Commit

Permalink
Deduplicate code between BV.get_bytes and BV.get_byte
Browse files Browse the repository at this point in the history
  • Loading branch information
twizmwazin committed Sep 20, 2024
1 parent 6ffd15e commit 3eb5c6d
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions claripy/ast/bv.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,7 @@ def get_byte(self, index):
:param index: the byte to extract
:return: An 8-bit BV
"""
pos = (self.size() + 7) // 8 - 1 - index
if pos < 0:
raise ValueError(
"Incorrect index %d. Your index must be between %d and %d." % (index, 0, self.size() // 8 - 1)
)
r = self[min(pos * 8 + 7, self.size() - 1) : pos * 8]
if r.size() % 8 != 0: # pylint:disable=no-member
r = r.zero_extend(8 - r.size() % 8) # pylint:disable=no-member
return r
return self.get_bytes(index, 1)

def get_bytes(self, index, size):
"""
Expand Down

0 comments on commit 3eb5c6d

Please sign in to comment.