diff --git a/Project.toml b/Project.toml index 1d931de..52070d4 100644 --- a/Project.toml +++ b/Project.toml @@ -28,3 +28,6 @@ julia = "1" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[targets] +test = ["Test"] \ No newline at end of file diff --git a/docs/src/release_notes.md b/docs/src/release_notes.md index f7a01f8..0e57c7b 100644 --- a/docs/src/release_notes.md +++ b/docs/src/release_notes.md @@ -1,6 +1,9 @@ # Release Notes +## 0.4.x +- Use StructArrays also for EDStore when building the model directly. + ## 0.4.0 ### New Functionality diff --git a/src/Components.jl b/src/Components.jl index b9c72e9..51e66fa 100644 --- a/src/Components.jl +++ b/src/Components.jl @@ -94,7 +94,7 @@ end Base.propertynames(oid::ObjectID) = tuple(fieldnames(ObjectID)...,:object) function register(p::ED) where ED collid = collectionID(ED) - store::Vector{ED} = EDStore_objects(ED, collid) + store = EDStore_objects(ED, collid) !iszero(p.index) && error("Registering an already registered MCParticle $p") last = lastindex(store) p = @set p.index = ObjectID{ED}(last, collid) diff --git a/src/EDStore.jl b/src/EDStore.jl index b99d653..547ef87 100644 --- a/src/EDStore.jl +++ b/src/EDStore.jl @@ -1,3 +1,5 @@ +using StructArrays + export EDStore, getEDStore, initEDStore, assignEDStore, emptyEDStore, assignEDStore_relations, assignEDStore_vmembers mutable struct EDStore{ED <: POD} @@ -8,13 +10,13 @@ mutable struct EDStore{ED <: POD} end function initialize!(store::EDStore{ED}) where ED <: POD - store.objects = ED[] + store.objects = StructArray(ED[]) store.relations = Tuple(ObjectID{eltype(R)}[] for R in relations(ED)) store.vmembers = Tuple(ObjectID{eltype(R)}[] for R in vmembers(ED)) end function Base.empty!(store::EDStore{ED}) where ED <: POD - store.objects isa Vector && empty!(store.objects) + store.objects isa StructArray & empty!(store.objects) for (i,R) in enumerate(relations(ED)) store.relations[i] isa Vector && empty!(store.relations[i]) end @@ -82,7 +84,7 @@ end function EDStore_objects(::Type{ED}, collid::UInt32=0x00000000) where ED store = getEDStore(ED, collid) if !isdefined(store, :objects) - store.objects = ED[] + store.objects = StructArray(ED[]) end store.objects end