Skip to content

Commit 195a9c7

Browse files
committed
minor optimizations
1 parent ad95017 commit 195a9c7

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

src/interface/interface.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@ The state is modified in-place.
4343
All keyword arguments are passed to the [`initialize_state!`](@ref)`(problem, algorithm, state)` function.
4444
"""
4545
function solve!(problem::Problem, algorithm::Algorithm, state::State; kwargs...)
46+
logger = ALGORITHM_LOGGER[]
4647
initialize_state!(problem, algorithm, state; kwargs...)
47-
log!(problem, algorithm, state, :Start)
48+
LOGGING_ENABLED[] && handle_message(logger, problem, algorithm, state, :Start)
4849
while !is_finished!(problem, algorithm, state)
49-
log!(problem, algorithm, state, :PreStep)
50+
LOGGING_ENABLED[] && handle_message(logger, problem, algorithm, state, :PreStep)
5051
increment!(state)
5152
step!(problem, algorithm, state)
52-
log!(problem, algorithm, state, :PostStep)
53+
LOGGING_ENABLED[] && handle_message(logger, problem, algorithm, state, :PostStep)
5354
end
54-
log!(problem, algorithm, state, :Stop)
55+
LOGGING_ENABLED[] && handle_message(logger, problem, algorithm, state, :Stop)
5556
return state
5657
end
5758

src/logging.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ end
125125
alglogger::AlgorithmLogger, problem::Problem, algorithm::Algorithm, state::State, context::Symbol;
126126
kwargs...
127127
)
128+
isempty(alglogger.actions) && return nothing
128129
action::LoggingAction = @something(get(alglogger.actions, context, nothing), return nothing)
129130
try
130131
handle_message!(action, problem, algorithm, state, args...; kwargs...)

0 commit comments

Comments
 (0)