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-1346] Compiling CGRect.init way slower than CGRectMake #43954

Closed
swift-ci opened this issue Apr 28, 2016 · 1 comment
Closed

[SR-1346] Compiling CGRect.init way slower than CGRectMake #43954

swift-ci opened this issue Apr 28, 2016 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself performance

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-1346
Radar None
Original Reporter mexx (JIRA User)
Type Bug
Status Closed
Resolution Invalid
Environment

OS X 10.11.4 (15E65)
Xcode Version 7.3.1 (7D1012)
Toolchain: Xcode Swift 2.2.1 Snapshot 2016-04-23 (a)

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

md5: da0a2ffc38a5c5d34b828a9ee4664273

Issue Description:

Given the following two functions, the second one takes more than 10 times as long to compile as the first one. (~60ms vs ~700ms on my machine)

The only difference is, that the first one uses `CGRectMake` and the second one uses `CGRect.init`

func drawFast() {
    let group: CGRect = .zero   // This would normaly not be .zero, but for sake of a smaller example, .zero is sufficient
    let rect = CGRectMake(group.minX + floor(group.width), group.minY + floor(group.height * 0.31667 - 0.49) + 0.99, floor(group.width * 0.82667 + 0.5) - floor(group.width * 0.71667 + 0.5), floor(group.height * 0.38667 - 0.49) - floor(group.height * 0.31667 - 0.49))
}

func drawSlow() {
    let group: CGRect = .zero   // This would normaly not be .zero, but for sake of a smaller example, .zero is sufficient
    let rect = CGRect(x: group.minX + floor(group.width), y: group.minY + floor(group.height * 0.31667 - 0.49) + 0.99, width: floor(group.width * 0.82667 + 0.5) - floor(group.width * 0.71667 + 0.5), height: floor(group.height * 0.38667 - 0.49) - floor(group.height * 0.31667 - 0.49))
}

Complete Gist: https://gist.github.com/iv-mexx/938c09ff4f9861bd7827f7f8611aa8b6

@Dante-Broggi
Copy link
Contributor

This bug is no longer valid, as `CGRectMake` is unavailable in swift.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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
Projects
None yet
Development

No branches or pull requests

2 participants