Skip to content

Commit

Permalink
Create flyweight factory for BasicSymbolic
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenszhu committed Oct 25, 2024
1 parent 2dac2a3 commit c2d85c3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,13 @@ end
### Constructors
###

function BasicSymbolic(s::BasicSymbolic)::BasicSymbolic
get!(wvd, hash2(s), s)
end

function Sym{T}(name::Symbol; kw...) where {T}
s = Sym{T}(; name, kw...)
get!(wvd, hash2(s), s)
BasicSymbolic(s)
end

function Term{T}(f, args; kw...) where T
Expand Down

0 comments on commit c2d85c3

Please sign in to comment.