@@ -311,31 +311,25 @@ function modify!(ds::AbstractDataset, @nospecialize(args...); threads::Bool = tr
311311 end
312312end
313313
314- # we must take care of all possible types, because, catching is very expensive
314+ # we must take care of all possible types, because, fallback is slow
315315_is_scalar (:: T , sz) where T <: Number = true
316316_is_scalar (:: Missing , sz) = true
317317_is_scalar (:: T , sz) where T <: Tuple = true
318318_is_scalar (:: TimeType , sz) = true
319319_is_scalar (:: T , sz) where T <: AbstractString = true
320320_is_scalar (x:: T , sz) where T <: AbstractVector = length (x) != sz
321- function _is_scalar (_res, sz)
321+
322+ # TODO can we memorise this and avoid calling it repeatedly in a sesssion
323+ _is_scalar_barrier (:: Val{T} ) where T = hasmethod (size, (T,))
324+
325+ function _is_scalar (_res:: T , sz) where T
322326 resize_col = false
323- try
324- size (_res)
327+ if _is_scalar_barrier (Val (T))
325328 if size (_res) == () || size (_res,1 ) != sz
326- # fill!(allocatecol(typeof(_res), nrow(ds)),
327- # _res)
328- # _res = repeat([_res], nrow(ds))
329329 resize_col = true
330330 end
331- catch e
332- if (e isa MethodError)
333- # fill!(allocatecol(typeof(_res), nrow(ds)),
334- # _res)
335- # _res = repeat([_res], nrow(ds))
336- resize_col = true
337- end
338-
331+ else
332+ resize_col = true
339333 end
340334 return resize_col
341335end
0 commit comments