Skip to content

Commit

Permalink
Actually optimize offsetc
Browse files Browse the repository at this point in the history
#184 was mistakenly merged
prior to completing the optimization. Specifically, `offsetc` should
call `altmod1` instead of `mod1`. The former returns early if it detects
that there is no wrapping.
  • Loading branch information
kbarros committed Nov 13, 2023
1 parent dd74968 commit 863761f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/System/System.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const Site = Union{NTuple{4, Int}, CartesianIndex{4}}
end

# Offset a `cell` by `ncells`
@inline offsetc(cell::CartesianIndex{3}, ncells, latsize) = CartesianIndex(mod1.(Tuple(cell) .+ Tuple(ncells), latsize))
@inline offsetc(cell::CartesianIndex{3}, ncells, latsize) = CartesianIndex(altmod1.(Tuple(cell) .+ Tuple(ncells), latsize))

# Split a site `site` into its cell and sublattice parts
@inline to_cell(site) = CartesianIndex((site[1],site[2],site[3]))
Expand Down

1 comment on commit 863761f

@Lazersmoke
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

Please sign in to comment.