Skip to content

Commit

Permalink
Avoid ntuple for fieldcount above 512
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Aug 6, 2023
1 parent f3fa24a commit 4d4c962
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Tables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,17 @@ function Base.getproperty(sch::Schema{names, types}, field::Symbol) where {names
return names === nothing ? getfield(sch, :storednames) : names
elseif field === :types
T = getfield(sch, :storedtypes)
return types === nothing ? (T !== nothing ? T : nothing) : ntuple(i -> fieldtype(types, i), Val(fieldcount(types)))
if types === nothing
return (T !== nothing ? T : nothing)
else
ncol = fieldcount(types)
if ncol <= 512
# Type stable, but slower to compile
return ntuple(i -> fieldtype(types, i), Val(ncol))
else
return Tuple(fieldtype(types, i) for i=1:ncol)

Check warning on line 511 in src/Tables.jl

View check run for this annotation

Codecov / codecov/patch

src/Tables.jl#L511

Added line #L511 was not covered by tests
end
end
else
throw(ArgumentError("unsupported property for Tables.Schema"))
end
Expand Down

0 comments on commit 4d4c962

Please sign in to comment.