From 2710d085345f766afd885a41050b8d98ccab74d3 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 7 Feb 2024 11:14:23 +0100 Subject: Julia: RefList: index using tuple I realised that separate h k l parameters leads to a profusion of argument splatting. --- julia/CrystFEL/src/reflists.jl | 9 +++++---- julia/CrystFEL/src/symmetry.jl | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/julia/CrystFEL/src/reflists.jl b/julia/CrystFEL/src/reflists.jl index e1766f83..6629b186 100644 --- a/julia/CrystFEL/src/reflists.jl +++ b/julia/CrystFEL/src/reflists.jl @@ -93,11 +93,12 @@ Base.length(reflist::RefList) = ccall((:num_reflections, libcrystfel), Cint, (Ptr{InternalRefList},), reflist.internalptr) -function Base.getindex(reflist::RefList{T}, h, k, l) where T +function Base.getindex(reflist::RefList{T}, indices) where T - refl = ccall((:find_refl, libcrystfel), - Ptr{InternalReflection}, (Ptr{InternalRefList},Cint,Cint,Cint), - reflist.internalptr, h, k, l) + refl = @ccall libcrystfel.find_refl(reflist.internalptr::Ptr{InternalRefList}, + indices[1]::Cint, + indices[2]::Cint, + indices[3]::Cint)::Ptr{InternalReflection} if refl == C_NULL return nothing diff --git a/julia/CrystFEL/src/symmetry.jl b/julia/CrystFEL/src/symmetry.jl index d6d2e477..4b4caa4d 100644 --- a/julia/CrystFEL/src/symmetry.jl +++ b/julia/CrystFEL/src/symmetry.jl @@ -100,12 +100,12 @@ function Base.iterate(sym::SymOpList, i) end -function asymmetricindices(sym::SymOpList, h, k, l) +function asymmetricindices(sym::SymOpList, indices) ho = Ref{Cint}(0) ko = Ref{Cint}(0) lo = Ref{Cint}(0) @ccall libcrystfel.get_asymm(sym.internalptr::Ptr{InternalSymOpList}, - h::Cint, k::Cint, l::Cint, + indices[1]::Cint, indices[2]::Cint, indices[3]::Cint, ho::Ref{Cint}, ko::Ref{Cint}, lo::Ref{Cint})::Cvoid (ho[], ko[], lo[]) end -- cgit v1.2.3