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

a!! should be no-op if we know the variable is not null #1566

Open
i582 opened this issue Jan 24, 2025 · 1 comment
Open

a!! should be no-op if we know the variable is not null #1566

i582 opened this issue Jan 24, 2025 · 1 comment
Labels
feature: optionals Maybe types (Foo?) kind: gas! Gas consumption and fee-related things

Comments

@i582
Copy link
Contributor

i582 commented Jan 24, 2025

import "@stdlib/deploy";

contract Test with Deployable {
    get fun getValue(val: Int?): Int {
        if (val != null) {
            return val!!;
        }
        return 10
    }
}

Then we will save about 62 gas for each !!.

@i582 i582 added kind: gas! Gas consumption and fee-related things kind: performance Improve compiler/testing performance labels Jan 24, 2025
@anton-trunov anton-trunov added the feature: optionals Maybe types (Foo?) label Jan 25, 2025
@anton-trunov
Copy link
Member

We will remove the non-null runtime checks here: #1282 (with a config option). See also this related issue: #259.

@anton-trunov anton-trunov removed the kind: performance Improve compiler/testing performance label Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: optionals Maybe types (Foo?) kind: gas! Gas consumption and fee-related things
Projects
None yet
Development

No branches or pull requests

2 participants