Skip to content

Commit

Permalink
Hash consing for Sym
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenszhu committed Oct 16, 2024
1 parent 7e93ca4 commit 9be3d03
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,13 @@ end
### Constructors
###

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

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

0 comments on commit 9be3d03

Please sign in to comment.