Skip to content

Commit 5953d9d

Browse files
author
Pietro Vertechi
authored
Merge pull request #77 from piever/pv/nogen2
removed SkipConstructor
2 parents 0739d91 + aca302c commit 5953d9d

File tree

2 files changed

+2
-14
lines changed

2 files changed

+2
-14
lines changed

src/utils.jl

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ function buildfromschema(initializer, ::Type{T}, ::Type{NT}) where {T, NT<:Tup}
2323
StructArray{T}(nt)
2424
end
2525

26-
Base.@pure SkipConstructor(::Type) = false
27-
2826
@static if VERSION < v"1.2.0"
2927
@inline _getproperty(v::Tuple, field) = getfield(v, field)
3028
@inline _getproperty(v, field) = getproperty(v, field)
@@ -48,19 +46,9 @@ end
4846

4947
foreachfield(f, x::T, xs...) where {T} = foreachfield(staticschema(T), f, x, xs...)
5048

51-
function createinstance(::Type{T}, args...) where {T}
52-
SkipConstructor(T) ? unsafe_createinstance(T, args...) : T(args...)
53-
end
54-
49+
createinstance(::Type{T}, args...) where {T} = T(args...)
5550
createinstance(::Type{T}, args...) where {T<:Union{Tuple, NamedTuple}} = T(args)
5651

57-
@generated function unsafe_createinstance(::Type{T}, args...) where {T}
58-
v = fieldnames(T)
59-
new_tup = Expr(:(=), Expr(:tuple, v...), :args)
60-
construct = Expr(:new, :T, (:(convert(fieldtype(T, $(Expr(:quote, sym))), $sym)) for sym in v)...)
61-
Expr(:block, new_tup, construct)
62-
end
63-
6452
add_params(::Type{T}, ::Type{C}) where {T, C<:Tuple} = T
6553
add_params(::Type{T}, ::Type{C}) where {T<:Tuple, C<:Tuple} = C
6654
add_params(::Type{<:NamedTuple{names}}, ::Type{C}) where {names, C<:Tuple} = NamedTuple{names, C}

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ struct S
298298
S(x) = new(x, x)
299299
end
300300

301-
StructArrays.SkipConstructor(::Type{<:S}) = true
301+
StructArrays.createinstance(::Type{<:S}, x, y) = S(x)
302302

303303
@testset "inner" begin
304304
v = StructArray{S}(([1], [1]))

0 commit comments

Comments
 (0)