mirror of
https://github.com/capstone-engine/capstone.git
synced 2024-12-15 17:38:36 +00:00
python: optimize to_x() & to_x_32() for python3
This commit is contained in:
parent
5a46c146b5
commit
b1e14f913d
@ -53,7 +53,7 @@ def to_x(s):
|
||||
from struct import pack
|
||||
if not s: return '0'
|
||||
x = pack(">q", s)
|
||||
while x[0] == '\0': x = x[1:]
|
||||
while x[0] in ('\0', 0): x = x[1:]
|
||||
if _python3:
|
||||
return "".join("{0:02x}".format(c) for c in x) # <-- Python 3 is OK
|
||||
else:
|
||||
@ -63,7 +63,7 @@ def to_x_32(s):
|
||||
from struct import pack
|
||||
if not s: return '0'
|
||||
x = pack(">i", s)
|
||||
while x[0] == '\0': x = x[1:]
|
||||
while x[0] in ('\0', 0): x = x[1:]
|
||||
if _python3:
|
||||
return "".join("{0:02x}".format(c) for c in x) # <-- Python 3 is OK
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user