Skip to content

Commit 94336c1

Browse files
authored
Improve inference for DLMStore constructor (#24)
This reduces all arguments to concrete types before invoking the "real" constructor. This prevents invalidation due to novel integer types, etc.
1 parent 0e01474 commit 94336c1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/DelimitedFiles.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,19 @@ mutable struct DLMStore{T} <: DLMHandler
321321
eol::Char
322322
end
323323

324-
function DLMStore(::Type{T}, dims::NTuple{2,Integer},
325-
has_header::Bool, sbuff::String, auto::Bool, eol::AbstractChar) where T
324+
function DLMStore(::Type{T}, dims::NTuple{2,Int},
325+
has_header::Bool, sbuff::String, auto::Bool, eol::Char) where T
326326
(nrows,ncols) = dims
327327
nrows <= 0 && throw(ArgumentError("number of rows in dims must be > 0, got $nrows"))
328328
ncols <= 0 && throw(ArgumentError("number of columns in dims must be > 0, got $ncols"))
329329
hdr_offset = has_header ? 1 : 0
330330
DLMStore{T}(fill(SubString(sbuff,1,0), 1, ncols), Matrix{T}(undef, nrows-hdr_offset, ncols),
331-
nrows, ncols, 0, 0, hdr_offset, sbuff, auto, Char(eol))
331+
nrows, ncols, 0, 0, hdr_offset, sbuff, auto, eol)
332+
end
333+
function DLMStore(::Type{T}, dims::NTuple{2,Integer},
334+
has_header::Bool, sbuff::String, auto::Bool, eol::AbstractChar) where T
335+
nrows, ncols = dims
336+
DLMStore(T, (Int(nrows)::Int, Int(ncols)::Int), has_header, sbuff, auto, Char(eol)::Char)
332337
end
333338

334339
_chrinstr(sbuff::String, chr::UInt8, startpos::Int, endpos::Int) =

0 commit comments

Comments
 (0)