3535@inline function parsecustom! (:: Type{customtypes} , row_bytes, pos, len, col_idx, cols, options, _type) where {customtypes}
3636 if @generated
3737 block = Expr (:block )
38+ pushfirst! (block. args, :(error (lazy " Unreachable: type not matched" )))
3839 for i = 1 : fieldcount (customtypes)
3940 T = fieldtype (customtypes, i)
4041 pushfirst! (block. args, quote
4142 if type === $ T
4243 res = Parsers. xparse ($ T, row_bytes, pos, len, options):: Parsers.Result{$T}
4344 (val, tlen, code) = res. val, res. tlen, res. code
4445 unsafe_push! (cols[col_idx]:: BufferedVector{$T} , val)
45- return val, tlen, code
46+ return tlen, code
4647 end
4748 end )
4849 end
5556 res = Parsers. xparse (_type, row_bytes, pos, len, options):: Parsers.Result{_type}
5657 (val, tlen, code) = res. val, res. tlen, res. code
5758 unsafe_push! (cols[col_idx]:: BufferedVector{_type} , val)
58- return val, tlen, code
59+ return tlen, code
5960 end
6061end
6162
@@ -74,7 +75,8 @@ function ChunkedBase.populate_result_buffer!(
7475 errored_idx = 1
7576 options = parsing_ctx. options
7677
77- Base. ensureroom (result_buf, ceil (Int, length (newlines_segment) * 1.01 ))
78+ # If we need to grow the buffer, we add a bit of extra room to avoid having to reallocate too often
79+ capacity (result_buf) < (length (newlines_segment)- 1 ) && Base. ensureroom (result_buf, ceil (Int, length (newlines_segment) * 1.01 ))
7880
7981 ignorerepeated = options. ignorerepeated:: Bool
8082 ignoreemptyrows = options. ignoreemptylines:: Bool
@@ -163,7 +165,7 @@ function ChunkedBase.populate_result_buffer!(
163165 (val, tlen, code) = res. val, res. tlen, res. code
164166 unsafe_push! (cols[col_idx]:: BufferedVector{Parsers.PosLen31} , Parsers. PosLen31 (prev_newline+ val. pos, val. len, val. missingvalue, val. escapedvalue))
165167 else
166- (val, tlen, code) = parsecustom! (CT, row_bytes, pos, len, col_idx, cols, options, schema[col_idx])
168+ (tlen, code) = parsecustom! (CT, row_bytes, pos, len, col_idx, cols, options, schema[col_idx])
167169 end
168170 if Parsers. sentinel (code)
169171 row_status |= RowStatus. MissingValues
0 commit comments