Skip to content

Commit

Permalink
fix lint, add notes
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Jul 16, 2023
1 parent b81a909 commit 35bc569
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
17 changes: 6 additions & 11 deletions vyper/codegen/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,7 @@
)
from vyper.semantics.types.bytestrings import _BytestringT
from vyper.semantics.types.shortcuts import BYTES32_T, UINT256_T
from vyper.utils import (
DECIMAL_DIVISOR,
bytes_to_int,
is_checksum_encoded,
string_to_bytes,
vyper_warn,
)
from vyper.utils import DECIMAL_DIVISOR, is_checksum_encoded, string_to_bytes, vyper_warn

ENVIRONMENT_VARIABLES = {"block", "msg", "tx", "chain"}

Expand Down Expand Up @@ -142,15 +136,16 @@ def _make_bytelike(self, btype, bytez, bytez_length):
assert isinstance(bytez, bytes)
label = _freshname("bytesdata")
len_ = len(bytez)
# NOTE: addl opportunities for optimization:
# - intern repeated bytestrings
# - instantiate into memory lazily, pass around bytestring
# literals in IR.
ret.append(["data", label, bytez])
ret.append(["codecopy", placeholder + 32, ["symbol", label], len_])
ret.append(["mstore", placeholder, len_])
ret.append(placeholder)
return IRnode.from_list(
ret,
typ=btype,
location=MEMORY,
annotation=f"Create {btype}: {bytez}",
ret, typ=btype, location=MEMORY, annotation=f"Create {btype}: {repr(bytez)}"
)

# True, False, None constants
Expand Down
1 change: 1 addition & 0 deletions vyper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def hex_to_int(inp):


# Converts bytes to an integer
# TODO: use int.from_bytes
def bytes_to_int(bytez):
o = 0
for b in bytez:
Expand Down

0 comments on commit 35bc569

Please sign in to comment.