Skip to content

Reduce size of generated code for lazy fields #5446

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

Merged
merged 1 commit into from
Nov 15, 2018

Conversation

allanrenucci
Copy link
Contributor

@allanrenucci allanrenucci commented Nov 15, 2018

For lazy val x = <RHS>:

Before:

def x() =
  if (flag) target
  else {
    target = <RHS>
    flag = true
    target
  }

After:

def x() = {
  if (!flag) {
    target = <RHS>
    flag = true
  }
  target
}

For `lazy val x = <RHS>`:

Before:
```
def x() =
  if (flag) target
  else {
    target = <RHS>
    flag = true
    target
  }
```

After:
```scala
def x() = {
  if(!flag) {
    target = <RHS>
    flag = true
  }
  target
}
```
@allanrenucci allanrenucci merged commit 57f3efb into scala:master Nov 15, 2018
@allanrenucci allanrenucci deleted the lazy-vals branch November 15, 2018 14:59
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

Successfully merging this pull request may close these issues.

2 participants