Skip to content

Commit

Permalink
Merge #36
Browse files Browse the repository at this point in the history
36: Fix performance bug r=charleskawczynski a=charleskawczynski

This PR fixes a performance bug related to an unused type parameter, `, IT <: Int` for the NewtonMethod solver.
On master, Thermodynamics shows `176 bytes` allocated for the `PhaseEquil_ρeq` constructor
On this branch, Thermodynamics shows no allocations for the `PhaseEquil_ρeq` constructor

This PR also changes `maxiters::Union{Nothing, Int}` to `maxiters::Int` since it can't actually work with nothing passed.

Co-authored-by: Charles Kawczynski <[email protected]>
  • Loading branch information
bors[bot] and charleskawczynski authored May 23, 2022
2 parents 8f2178d + 02dd9cd commit 3e8975e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RootSolvers"
uuid = "7181ea78-2dcb-4de3-ab41-2b8ab5a31e74"
authors = ["CliMA Contributors <[email protected]>"]
version = "0.3.0"
version = "0.3.1"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand Down
8 changes: 4 additions & 4 deletions src/RootSolvers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ Evaluates solution tolerance, based on ``|x2-x1|``
method::RootSolvingMethod{FT},
soltype::SolutionType,
tol::Union{Nothing, AbstractTolerance} = nothing,
maxiters::Union{Nothing, Int} = 10_000,
maxiters::Int = 10_000,
)
Finds the nearest root of `f`. Returns a the value of the root `x` such
Expand All @@ -234,7 +234,7 @@ function find_zero(
method::RootSolvingMethod{FT},
soltype::SolutionType,
tol::Union{Nothing, AbstractTolerance} = nothing,
maxiters::Union{Nothing, Int} = 10_000,
maxiters::Int = 10_000,
) where {FT <: FTypes, F <: Function}
if tol === nothing
tol = SolutionTolerance{eltype(FT)}(1e-3)
Expand All @@ -249,7 +249,7 @@ function Broadcast.broadcasted(
method::RootSolvingMethod{FT},
soltype::SolutionType,
tol::Union{Nothing, AbstractTolerance} = nothing,
maxiters::Union{Nothing, Int} = 10_000,
maxiters::Int = 10_000,
) where {FT <: FTypes, F}
if tol === nothing
tol = SolutionTolerance{eltype(FT)}(1e-3)
Expand Down Expand Up @@ -453,7 +453,7 @@ function find_zero(
soltype::SolutionType,
tol::AbstractTolerance{FT},
maxiters::Int,
) where {F <: Function, F′ <: Function, FT, IT <: Int}
) where {F <: Function, F′ <: Function, FT}
x_history = init_history(soltype, FT)
y_history = init_history(soltype, FT)
if soltype isa VerboseSolution
Expand Down

2 comments on commit 3e8975e

@charleskawczynski
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/60892

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.1 -m "<description of version>" 3e8975e50392ceb919232fae981aa62269fa604f
git push origin v0.3.1

Please sign in to comment.