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

[SR-13799] Boolean Comparison Extremely Slow #56196

Open
swift-ci opened this issue Oct 30, 2020 · 2 comments
Open

[SR-13799] Boolean Comparison Extremely Slow #56196

swift-ci opened this issue Oct 30, 2020 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself performance type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-13799
Radar rdar://problem/70892080
Original Reporter DeskA (JIRA User)
Type Bug
Environment

Swift 5.3

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: db9c4c36968f95770af1e55b5bdecdbc

Issue Description:

```
public override func hasItems(in: Store) -> Bool {
guard let items = store.storage?.items else { return false }
let hasNoItems: Bool = items.isEmpty
return hasNoItems == false
}
```
This takes 400ms to type-check.

```
public override func hasItems(in: Store) -> Bool {
guard let items = store.storage?.items else { return false }
return !items.isEmpty
}
```
This takes less than 10ms to type-check.

Boolean comparisons are extremely slow when compiling swift. It's well known that swift is a slow language, but this seems extreme.

@typesanitizer
Copy link

@swift-ci create

@swift-ci
Copy link
Collaborator Author

Comment by DeskA (JIRA)

The cause of this seems to be that BooleanLiteralType is reassignable, so for the odd chance that someone does that, swift is incredibly slow.

I know that swift is a minefield of performance issues and slow type checking, but it would be nice to fix this and hsve a compiler shortcut

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself performance type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants