Skip to content

Commit d83b33e

Browse files
committed
Update Attributes.jl
Optimise setindex! for columnar attributes
1 parent c69153b commit d83b33e

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/types/Attributes.jl

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -641,13 +641,7 @@ function Base.get(attrs::ColumnarAttrs, key::Symbol, default::T) where {T}
641641
end
642642
Base.get(attrs::ColumnarAttrs, key, default) = get(attrs, _normalize_attr_key(key), default)
643643

644-
function Base.setindex!(attrs::ColumnarAttrs, value::T, key::Symbol) where {T}
645-
if !_isbound(attrs)
646-
attrs.staged[key] = value
647-
return value
648-
end
649-
store, bid, row = _bound_store_bid_row(attrs.ref)
650-
bucket = store.buckets[bid]
644+
@inline function _set_value_bound!(bucket::SymbolBucket, row::Int, key::Symbol, value::T) where {T}
651645
col_idx = get(bucket.col_index, key, 0)
652646
if col_idx == 0
653647
_set_value!(bucket, row, key, value)
@@ -666,6 +660,17 @@ function Base.setindex!(attrs::ColumnarAttrs, value::T, key::Symbol) where {T}
666660

667661
return value
668662
end
663+
664+
function Base.setindex!(attrs::ColumnarAttrs, value::T, key::Symbol) where {T}
665+
if !_isbound(attrs)
666+
attrs.staged[key] = value
667+
return value
668+
end
669+
store, bid, row = _bound_store_bid_row(attrs.ref)
670+
bucket = store.buckets[bid]
671+
_set_value_bound!(bucket, row, key, value)
672+
return value
673+
end
669674
Base.setindex!(attrs::ColumnarAttrs, value, key) = setindex!(attrs, value, _normalize_attr_key(key))
670675

671676
function Base.iterate(attrs::ColumnarAttrs, state=nothing)

0 commit comments

Comments
 (0)