-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Previous ID | SR-8913 |
Radar | rdar://problem/45049364 |
Original Reporter | @YOCKOW |
Type | Improvement |
Attachment: Download
Environment
-
OS: macOS Mojave
-
Swift: 4.2
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Improvement |
Assignee | None |
Priority | Medium |
md5: f188e3d745da38e11c104ef33cce615e
Issue Description:
Please see the attached file named "conditions.swift"
There are 6 functions in the source, and each of them contains 2,000 "if", "else if", or "switch case" statements. (They will return the same result with the same argument, though that is not essential.)
Now, type the following command to compile the source:
swiftc -Xfrontend -warn-long-function-bodies=1 conditions.swift
Then, the messages like below will be viewed.
conditions.swift:1:13: warning: global function 'function_if' took 1179ms to type-check (limit: 1ms)
public func function_if(_ integer:Int) -> Int {
^
conditions.swift:2006:13: warning: global function 'function_if_without_print' took 738ms to type-check (limit: 1ms)
public func function_if_without_print(_ integer:Int) -> Int {
^
conditions.swift:4011:13: warning: global function 'function_else_if' took 23861ms to type-check (limit: 1ms)
public func function_else_if(_ integer:Int) -> Int {
^
conditions.swift:6016:13: warning: global function 'function_else_if_without_print' took 599ms to type-check (limit: 1ms)
public func function_else_if_without_print(_ integer:Int) -> Int {
^
conditions.swift:8021:13: warning: global function 'function_switch' took 916ms to type-check (limit: 1ms)
public func function_switch(_ integer:Int) -> Int {
^
conditions.swift:10028:13: warning: global function 'function_switch_without_print' took 612ms to type-check (limit: 1ms)
public func function_switch_without_print(_ integer:Int) -> Int {
^
It seems that it takes significantly much time to compile "function_else_if" compared with other functions.
Furthermore, the compilation time seems to depend on the contents of code block even if there are the same number of "else if"s.