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

Dafny-to-Rust Performance improvement: access sequence by usize, not int #5850

Open
Tracked by #5561
MikaelMayer opened this issue Oct 22, 2024 · 0 comments
Open
Tracked by #5561

Comments

@MikaelMayer
Copy link
Member

Consider the following code:

  method First(s: seq<int>) requires |s| != 0 returns (j: int) {
    return s[0]
  }

It will emit the equivalent of

  fn First(s: Sequence<DafnyInt>) -> DafnyInt {
    s.get(int!(0))
  }

which results in a conversion of 0 to DafnyInt and then back to a usize
We could get rid of this conversion issue by emitting

  s.get_usize(truncate!(int!(0), usize))

because in that case, the expression simplifier would just replace it with

  s.get_usize(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant