erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.62k stars 54 forks source link

refactor: use next_back and match #392

Closed GreasySlug closed 1 year ago

mtshiba commented 1 year ago

This implementation is incorrect. Because .iter().next_back() always returns the same element. Also, VecDeque's reverse iterator uses next_back() internally, so there is no need to change the iteration part.

mtshiba commented 1 year ago

In general, element traversal is most efficient with a for statement. This is because it allows optimization for boundary checks. This is also true when using VecDeque.

GreasySlug commented 1 year ago

Okay, this PR was meant to be a discussion, so, I'll close it