@@ -57,14 +57,7 @@ This function enables seamless switching between regular and automatic different
5757computations without manual cache management.
5858"""
5959function get_tmp (dc:: FixedSizeDiffCache , u:: Union{Number, AbstractArray} )
60- if promote_type (eltype (dc. du), eltype (u)) <: eltype (dc. du)
61- dc. du
62- else
63- if length (dc. du) > length (dc. any_du)
64- resize! (dc. any_du, length (dc. du))
65- end
66- _restructure (dc. du, dc. any_du)
67- end
60+ get_tmp (dc, eltype (u))
6861end
6962
7063function get_tmp (dc:: FixedSizeDiffCache , :: Type{T} ) where {T <: Number }
@@ -171,10 +164,12 @@ elements and issues a one-time warning suggesting an appropriate chunk size for
171164optimal performance.
172165
173166## Arguments
167+
174168 - `dc`: The `DiffCache` object to enlarge
175169 - `nelem`: The new required number of elements
176170
177171## Notes
172+
178173The warning is shown only once per `DiffCache` instance to avoid spam. For optimal
179174performance in production code, pre-allocate with the suggested chunk size to avoid
180175runtime allocations.
@@ -273,7 +268,7 @@ function Base.resize!(dc::DiffCache, n::Integer)
273268 else
274269 throw (ArgumentError (" resize! is only supported for DiffCache with vector arrays, got $(typeof (dc. du)) " ))
275270 end
276- # dual_du is often pre-allocated for ForwardDiff dual numbers,
271+ # dual_du is often pre-allocated for ForwardDiff dual numbers,
277272 # and may need special handling based on chunk size
278273 # Only resize if it's a vector
279274 if dc. dual_du isa AbstractVector
0 commit comments