Skip to content

Commit

Permalink
small memory optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
bbejanov committed Oct 5, 2023
1 parent 4ed9bec commit b6bdcbb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ Manifest.toml
coverage
*.cov

*.mem

docs/build
docs/Manifest.toml
4 changes: 2 additions & 2 deletions src/mvtseries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -477,12 +477,12 @@ end

# single argument - list/tuple of variables - return a TSeries of the column
@inline function Base.getindex(x::MVTSeries, cols::_MVTSAxes2)
inds = [_colind(x, c) for c in cols]
inds = _colind(x, cols)
return MVTSeries(firstdate(x), cols, getindex(_vals(x), :, inds))
end

@inline function Base.setindex!(x::MVTSeries, val, cols::_MVTSAxes2)
inds = [_colind(x, c) for c in cols]
inds = _colind(x, cols)
setindex!(x.values, val, :, inds)
end

Expand Down
5 changes: 4 additions & 1 deletion src/tseries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,10 @@ Base.copyto!(dest::TSeries, drng::AbstractRange{<:MIT}, src::TSeries) = mixed_fr
function Base.copyto!(dest::TSeries{F}, drng::AbstractRange{MIT{F}}, src::TSeries{F}) where {F<:Frequency}
fullindex = union(rangeof(dest), drng)
resize!(dest, fullindex)
copyto!(dest.values, Int(first(drng) - firstindex(dest) + 1), src[drng].values, 1, length(drng))
fd = Int(first(drng))
d1 = fd - Int(firstindex(dest)) + 1
s1 = fd - Int(firstindex(src)) + 1
copyto!(dest.values, d1, src.values, s1, length(drng))
return dest
end

Expand Down
2 changes: 1 addition & 1 deletion src/workspaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Base.setproperty!(w::Workspace, sym::Symbol, val) = setindex!(w, val, sym)
# MacroTools.@forward Workspace._c (Base.getindex,)
Base.getindex(w::Workspace, sym) = getindex(_c(w), convert(Symbol, sym))
Base.getindex(w::Workspace, sym, syms...) = getindex(w, (sym, syms...,))
Base.getindex(w::Workspace, syms::Vector) = getindex(w, (syms...,))
Base.getindex(w::Workspace, syms::Vector) = Workspace(convert(Symbol, s) => w[s] for s in syms)
Base.getindex(w::Workspace, syms::Tuple) = Workspace(convert(Symbol, s) => w[s] for s in syms)

MacroTools.@forward Workspace._c (Base.setindex!,)
Expand Down

0 comments on commit b6bdcbb

Please sign in to comment.