Skip to content

Commit

Permalink
faster structarray creation
Browse files Browse the repository at this point in the history
  • Loading branch information
aplavin committed Mar 3, 2023
1 parent 569c70e commit e335d28
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "StructArrays"
uuid = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
version = "0.6.14"
version = "0.6.15"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
6 changes: 3 additions & 3 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ maybe_convert_elt(::Type{T}, vals::NamedTuple) where T = T<:NamedTuple ? convert
Compute the unique value that `f` takes on each `component ∈ componenents`.
If not all values are equal, return `nothing`. Otherwise, return the unique value.
"""
function findconsistentvalue(f::F, (col, cols...)::Tup) where F
val = f(col)
isconsistent = mapfoldl(isequal(val)f, &, cols; init=true)
function findconsistentvalue(f::F, cols::Tup) where F
val = f(first(cols))
isconsistent = all(map(isequal(val) f, values(cols)))
return ifelse(isconsistent, val, nothing)
end

0 comments on commit e335d28

Please sign in to comment.