Skip to content

Commit

Permalink
fix[codegen]: fix gas usage of iterators
Browse files Browse the repository at this point in the history
cd31867 introduces a gas regression, which is that
`IRnode.is_literal` evaluates to true even for pointers (which are not
source-level literals). this commit changes the condition to be
`not .is_pointer`, which should be the correct condition for needing to
strictify into memory.
  • Loading branch information
charles-cooper committed Feb 21, 2025
1 parent a466dc8 commit 4819e4c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 0 additions & 2 deletions vyper/codegen/ir_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,6 @@ def int_value(self) -> int:

@property
def is_pointer(self) -> bool:
# not used yet but should help refactor/clarify downstream code
# eventually
return self.location is not None

@property # probably could be cached_property but be paranoid
Expand Down
4 changes: 2 additions & 2 deletions vyper/codegen/stmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ def _parse_For_list(self):

ret = ["seq"]

# list literal, force it to memory first
if iter_list.is_literal:
# if it's a list literal, force it to memory first
if not iter_list.is_pointer:
tmp_list = self.context.new_internal_variable(iter_list.typ)
ret.append(make_setter(tmp_list, iter_list))
iter_list = tmp_list
Expand Down

0 comments on commit 4819e4c

Please sign in to comment.