Skip to content

Commit eabfd9e

Browse files
asinghvi17rafaqz
andauthored
Improve column read speed by removing type instability (#33)
* 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]>
1 parent f22fcf5 commit eabfd9e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/DBFTables.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,9 @@ function Base.getproperty(dbf::Table, name::Symbol)
452452
nrow = header.records
453453
@inbounds field = getfields(dbf)[col]
454454
str = getstrings(dbf)
455-
@inbounds colarr = [julia_value(field, str[col, i]) for i = 1:nrow]
456-
return colarr
455+
FT = field.type
456+
FV = Val{field.dbf_type}()
457+
return @inbounds Union{FT, Missing}[julia_value(FT, FV, str[col, i]) for i = 1:nrow]
457458
end
458459

459460

0 commit comments

Comments
 (0)