Skip to content

Commit b5ec985

Browse files
committed
more getfield(layout, :array)
1 parent 2ae7a62 commit b5ec985

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

src/all_implementations.jl

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,21 +2089,18 @@ slot(
20892089
) where {FIELDS,CONTENTS<:Base.Tuple{Vararg{Content}},BEHAVIOR} = layout[f]
20902090

20912091
"""
2092-
Base.getindex(
2093-
layout::Record{FIELDS,CONTENTS},
2094-
f::Symbol,
2095-
) where {FIELDS,CONTENTS<:Base.Tuple{Vararg{Content}}}
2096-
20972092
Base.getindex(
20982093
layout::AwkwardArray.Record,
20992094
f::Symbol,
2100-
) = getfield(layout, :array).contents[f][getfield(layout, :at)]
2095+
)
21012096
"""
21022097
Base.getindex(
21032098
layout::AwkwardArray.Record,
21042099
f::Symbol,
21052100
) = getfield(layout, :array).contents[f][getfield(layout, :at)]
21062101

2102+
Base.getproperty(layout::Record, f::Symbol) = layout[f]
2103+
21072104
"""
21082105
Base.:(==)(
21092106
layout1::RecordArray{FIELDS,CONTENTS1},
@@ -2393,15 +2390,16 @@ end
23932390

23942391
"""
23952392
Base.getindex(
2396-
layout::SlotRecord{CONTENTS},
2393+
layout::SlotRecord,
23972394
f::Int64,
2398-
) where {CONTENTS<:Base.Tuple{Vararg{Content}}}
2395+
)
23992396
"""
24002397
Base.getindex(
2401-
layout::SlotRecord{CONTENTS},
2398+
layout::SlotRecord,
24022399
f::Int64,
2403-
) where {CONTENTS<:Base.Tuple{Vararg{Content}}} =
2404-
layout.array.contents[f][layout.at]
2400+
) = getfield(layout, :array).contents[f][getfield(layout, :at)]
2401+
2402+
Base.getproperty(layout::SlotRecord, f::Symbol) = layout[f]
24052403

24062404
"""
24072405
Base.:(==)(
@@ -2450,7 +2448,7 @@ function Base.:(==)(
24502448
CONTENTS1<:Base.Tuple{Vararg{Content,N}},
24512449
CONTENTS2<:Base.Tuple{Vararg{Content,N}},
24522450
}
2453-
for i in eachindex(layout1.array.contents) # same number of indexes by type constraint
2451+
for i in eachindex(getfield(layout1, :array).contents) # same number of indexes by type constraint
24542452
if layout1[i] != layout2[i] # compare tuple items
24552453
return false
24562454
end
@@ -4007,8 +4005,8 @@ Base.getindex(layout::UnionArray, f::Symbol) =
40074005
function Base.push!(special::Specialization, input)
40084006
tmp = length(special.tagged)
40094007
push!(special.tagged, input)
4010-
push!(special.array.tags, special.tag - firstindex(special.array.contents))
4011-
push!(special.array.index, tmp)
4008+
push!(getfield(special, :array).tags, special.tag - firstindex(getfield(special, :array).contents))
4009+
push!(getfield(special, :array).index, tmp)
40124010
special
40134011
end
40144012

@@ -4028,8 +4026,8 @@ end
40284026
function end_list!(special::Specialization)
40294027
tmp = length(special.tagged)
40304028
end_list!(special.tagged)
4031-
push!(special.array.tags, special.tag - firstindex(special.array.contents))
4032-
push!(special.array.index, tmp)
4029+
push!(getfield(special, :array).tags, special.tag - firstindex(getfield(special, :array).contents))
4030+
push!(getfield(special, :array).index, tmp)
40334031
special
40344032
end
40354033

@@ -4039,8 +4037,8 @@ end
40394037
function end_record!(special::Specialization)
40404038
tmp = length(special.tagged)
40414039
end_record!(special.tagged)
4042-
push!(special.array.tags, special.tag - firstindex(special.array.contents))
4043-
push!(special.array.index, tmp)
4040+
push!(getfield(special, :array).tags, special.tag - firstindex(getfield(special, :array).contents))
4041+
push!(getfield(special, :array).index, tmp)
40444042
special
40454043
end
40464044

@@ -4050,8 +4048,8 @@ end
40504048
function end_tuple!(special::Specialization)
40514049
tmp = length(special.tagged)
40524050
end_tuple!(special.tagged)
4053-
push!(special.array.tags, special.tag - firstindex(special.array.contents))
4054-
push!(special.array.index, tmp)
4051+
push!(getfield(special, :array).tags, special.tag - firstindex(getfield(special, :array).contents))
4052+
push!(getfield(special, :array).index, tmp)
40554053
special
40564054
end
40574055

@@ -4065,8 +4063,8 @@ function push_null!(
40654063
) where {ARRAY<:UnionArray,TAGGED<:OptionType}
40664064
tmp = length(special.tagged)
40674065
push_null!(special.tagged)
4068-
push!(special.array.tags, special.tag - firstindex(special.array.contents))
4069-
push!(special.array.index, tmp)
4066+
push!(getfield(special, :array).tags, special.tag - firstindex(getfield(special, :array).contents))
4067+
push!(getfield(special, :array).index, tmp)
40704068
special
40714069
end
40724070

@@ -4076,8 +4074,8 @@ end
40764074
function push_dummy!(special::Specialization)
40774075
tmp = length(special.tagged)
40784076
push_dummy!(special.tagged)
4079-
push!(special.array.tags, special.tag - firstindex(special.array.contents))
4080-
push!(special.array.index, tmp)
4077+
push!(getfield(special, :array).tags, special.tag - firstindex(getfield(special, :array).contents))
4078+
push!(getfield(special, :array).index, tmp)
40814079
special
40824080
end
40834081

@@ -4241,7 +4239,7 @@ to_vector(
42414239
view::Bool = false,
42424240
na::Union{Missing,Nothing} = missing,
42434241
) where {FIELDS,CONTENTS<:Base.Tuple{Vararg{Content}}} = NamedTuple{FIELDS}(
4244-
to_vector_or_scalar(record.array.contents[f][record.at], view = view, na = na) for
4242+
to_vector_or_scalar(getfield(record, :array).contents[f][record.at], view = view, na = na) for
42454243
f in FIELDS
42464244
)
42474245

@@ -4258,7 +4256,7 @@ to_vector(
42584256
na::Union{Missing,Nothing} = missing,
42594257
) where {CONTENTS<:Base.Tuple{Vararg{Content}}} = Base.Tuple(
42604258
to_vector_or_scalar(content[record.at], view = view, na = na) for
4261-
content in tuple.array.contents
4259+
content in getfield(tuple, :array).contents
42624260
)
42634261

42644262
"""
@@ -4736,7 +4734,7 @@ function _horizontal(data::Any, limit_cols::Int)
47364734
limit_cols -= 5 # anticipate the ", ..."
47374735

47384736
which = 0
4739-
fields = keys(data.array.contents)
4737+
fields = keys(getfield(data, :array).contents)
47404738
for field in fields
47414739
key = Base.string(field)
47424740

@@ -4803,7 +4801,7 @@ function _horizontal(data::Any, limit_cols::Int)
48034801
limit_cols -= 5 # anticipate the ", ..."
48044802

48054803
which = 0
4806-
fields = eachindex(data.array.contents)
4804+
fields = eachindex(getfield(data, :array).contents)
48074805
for field in fields
48084806
if which == 0
48094807
for_comma = 0
@@ -4921,7 +4919,7 @@ function _vertical(data::Union{Content,Record,Tuple}, limit_rows::Int, limit_col
49214919
front = Vector{String}([]) # 1-indexed
49224920

49234921
which = 0
4924-
fields = keys(data.array.contents)
4922+
fields = keys(getfield(data, :array).contents)
49254923
for field in fields
49264924
key = Base.string(field)
49274925
if occursin(r"^[A-Za-z_][A-Za-z_0-9]*$", key)
@@ -4962,7 +4960,7 @@ function _vertical(data::Union{Content,Record,Tuple}, limit_rows::Int, limit_col
49624960
front = Vector{String}([]) # 1-indexed
49634961

49644962
which = 0
4965-
fields = eachindex(data.array.contents)
4963+
fields = eachindex(getfield(data, :array).contents)
49664964
for field in fields
49674965
(_, strs) = _horizontal(data[field], limit_cols - 2)
49684966
push!(front, join(strs, ""))

0 commit comments

Comments
 (0)