Skip to content

Commit ba34d89

Browse files
for arrays when the CF transformation does not change the element type to avoid the allocation of a new array
1 parent 00eca36 commit ba34d89

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/cfvariable.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,12 @@ end
384384
return CFtransformdata!(out,data,fv,scale_factor,add_offset,time_origin,time_factor,maskingvalue)
385385
end
386386

387+
# for arrays when the CF transformation does not change the element type
388+
# to avoid the allocation of a new array
389+
@inline function CFtransformdata(data::AbstractArray{T,N},fv,scale_factor,add_offset,time_origin,time_factor,maskingvalue,::Type{T}) where {T,N}
390+
return CFtransformdata!(data,data,fv,scale_factor,add_offset,time_origin,time_factor,maskingvalue)
391+
end
392+
387393
@inline function CFtransformdata(
388394
data::AbstractArray{T,N},fv::Tuple{},scale_factor::Nothing,
389395
add_offset::Nothing,time_origin::Nothing,time_factor::Nothing,maskingvalue,::Type{T}) where {T,N}

0 commit comments

Comments
 (0)