Skip to content
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

perf[venom]: add OrderedSet.last() #4236

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions vyper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def __repr__(self):
def __iter__(self):
return iter(self._data)

def __reversed__(self):
return reversed(self._data)

def __contains__(self, item):
return self._data.__contains__(item)

Expand All @@ -45,6 +48,9 @@ def __len__(self):
def first(self):
return next(iter(self))

def last(self):
return next(reversed(self))

def pop(self):
return self._data.popitem()[0]

Expand Down
2 changes: 1 addition & 1 deletion vyper/venom/venom_to_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def _generate_evm_for_instruction(
elif inst.output in next_liveness:
# peek at next_liveness to find the next scheduled item,
# and optimistically swap with it
next_scheduled = list(next_liveness)[-1]
next_scheduled = next_liveness.last()
self.swap_op(assembly, stack, next_scheduled)

return apply_line_numbers(inst, assembly)
Expand Down
Loading