I noticed that DGCharts amounted to a large portion of the compile times of our app, so I measured the times for evaluating expressions and function bodies by adding the below build flags:
It turned out that certain functions and expressions had evaluation times close to one second on an M1 Mac, so I added some help for the compiler to shorten those checking times.
As a result of these changes, the compile times have gone down from 6 s for the entire package to only 4 s — a 33 % decrease. Certain files still make out the bulk of the total compile time so a further refactoring of those files could enable higher parallelisation of compilation, but that would make this PR too big to review.
Goals :soccer:
Shorter compile times.
Implementation Details :construction:
Bracketing parts of certain long expressions such as -0.5 * (sqrt(1.0 - position * position) - 1.0)
Removing type conversions from Double to Double such as Double( sqrt(1 - position * position) )
Adding a guard to functions that consisted of just one big if statement
Adding a type specifier to variable declarations that instead used a type initialiser on a literal such as var maxW: CGFloat = 0.0
Testing Details :mag:
The tests still run as before.
To ease code review, it helps to turn on "hide white spaces" in Github's code review view.
I noticed that DGCharts amounted to a large portion of the compile times of our app, so I measured the times for evaluating expressions and function bodies by adding the below build flags:
It turned out that certain functions and expressions had evaluation times close to one second on an M1 Mac, so I added some help for the compiler to shorten those checking times.
As a result of these changes, the compile times have gone down from 6 s for the entire package to only 4 s — a 33 % decrease. Certain files still make out the bulk of the total compile time so a further refactoring of those files could enable higher parallelisation of compilation, but that would make this PR too big to review.
Goals :soccer:
Shorter compile times.
Implementation Details :construction:
-0.5 * (sqrt(1.0 - position * position) - 1.0)
Double
toDouble
such asDouble( sqrt(1 - position * position) )
guard
to functions that consisted of just one bigif
statementvar maxW: CGFloat = 0.0
Testing Details :mag:
The tests still run as before. To ease code review, it helps to turn on "hide white spaces" in Github's code review view.