Skip to content

Optimizing SpecificInd::zp(), SpecificInd::zm()? #1857

Open
@johnomotani

Description

@johnomotani

There's a check on the size of the argument to zp(int dz) and zm(int dz)

const inline SpecificInd zp(int dz = 1) const {
ASSERT3(dz >= 0);
dz = dz <= nz ? dz : dz % nz; //Fix in case dz > nz, if not force it to be in range
return {(ind + dz) % nz < dz ? ind - nz + dz : ind + dz, ny, nz};
}

It's not used very much, but the commonest use is with no argument. Instead of having the default argument of dz = 1, would it be worth having a special no-argument case that does not need the check on dz (as if nz == 1 the result is always 0 anyway)? And possibly another for zpp() and zmm() where we could have something like ASSERT3(nz >= 2); instead of always checking dz?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions