Skip to content

Commit

Permalink
Merge pull request #63 from JuliaObjects/less_generated
Browse files Browse the repository at this point in the history
less generated for NamedTupleConstructor
  • Loading branch information
jw3126 authored Jun 28, 2022
2 parents 9fa5044 + fa46076 commit 518a6b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/ConstructionBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ constructorof(::Type{<:NamedTuple{names}}) where names =

struct NamedTupleConstructor{names} end

@generated function (::NamedTupleConstructor{names})(args...) where names
quote
Base.@_inline_meta
$(NamedTuple{names, Tuple{args...}})(args)
end
@inline function (::NamedTupleConstructor{names})(args...) where names
NamedTuple{names}(args)
end

getproperties(o::NamedTuple) = o
Expand Down Expand Up @@ -157,6 +154,7 @@ setproperties_object(obj, patch::Tuple{}) = obj
obj = $obj
patch = $patch
"""
throw(ArgumentError(msg))
end
setproperties_object(obj, patch::NamedTuple{()}) = obj
function setproperties_object(obj, patch)
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ end
@test setproperties((a=1,), ()) === (a=1,)
@test setproperties((a=1,), NamedTuple()) === (a=1,)
@test setproperties(AB(1,2), ()) === AB(1,2)
@test_throws ArgumentError setproperties(AB(1,2), (10,))
@test setproperties(AB(1,2), NamedTuple()) === AB(1,2)

@test setproperties(AB(1,2), (a=2, b=3)) === AB(2,3)
Expand Down

0 comments on commit 518a6b8

Please sign in to comment.