Skip to content

Commit

Permalink
Improve column read speed by removing type instability (#33)
Browse files Browse the repository at this point in the history
* explicitly type the column returned by getproperty to avoid column unioning

* Extract type and char outside the array comprehension

This takes runtime from 42 ms to 13 ms

* Simplify code

Co-authored-by: Rafael Schouten <[email protected]>

---------

Co-authored-by: Rafael Schouten <[email protected]>
  • Loading branch information
asinghvi17 and rafaqz authored Apr 3, 2024
1 parent f22fcf5 commit eabfd9e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/DBFTables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,9 @@ function Base.getproperty(dbf::Table, name::Symbol)
nrow = header.records
@inbounds field = getfields(dbf)[col]
str = getstrings(dbf)
@inbounds colarr = [julia_value(field, str[col, i]) for i = 1:nrow]
return colarr
FT = field.type
FV = Val{field.dbf_type}()
return @inbounds Union{FT, Missing}[julia_value(FT, FV, str[col, i]) for i = 1:nrow]
end


Expand Down

0 comments on commit eabfd9e

Please sign in to comment.