Removed init_state
authorMark Abraham <mark.j.abraham@gmail.com>
Mon, 7 Nov 2016 15:59:59 +0000 (16:59 +0100)
committerMark Abraham <mark.j.abraham@gmail.com>
Sat, 21 Jan 2017 21:24:11 +0000 (22:24 +0100)
commitebca6513d836eca7944f8d1707c7637280eca64e
tree46b9d3dc13d5d62a2f4d26d1aa3e1ce314283bd8
parente29363eed26395d2573acc7f81cc4c3c1e5746fd
Removed init_state

Made a simple zero-initializing constructor for t_state and the
structs of some of its members. Called them classes. Later, we might
prefer to require explicit initialization with actual values, so that
tools can detect the use of uninitialized values and find our bugs,
but for now having a constructor is a useful initial step in that
direction.

Extracted some new functions that cover some of the incidental
functionality that was also present in init_state.

Made state.lambda a std::array, thereby removing the need to consider
resizing it, and converted client code to be passed an ArrayRef rather
than hard-code the name of the specific container. This caters for
convenient future refactoring of the underlying storage, and sometimes
needing to implicitly know what the size of the container is.

Passing an ArrayRef by value is consistent with the CppCoreGuidelines,
but has potential for performance impact. Doing this means that a
caller pushes onto the stack a copy of the object (containing two
pointers), rather than previous idioms such as pointer + size, or
pointer + implicit constant size from an enum, or pointer + implicit
size in some other parameter. This could mean an extra argument is
pushed to the stack for the function call, compared with the
alternatives of pushing a pointer to data, pointer to container, or
pointer to ArrayRef. In all cases, the caller has to load the pointer
value via an offset that is known to the compiler, so that aspect is
probably irrelevant. So, we would probably prefer to avoid calling
functions that take such parameters in a tight loop, or where multiple
containers share a common size. But the uses in this patch seem to be
of sufficiently high level to be an acceptable trade of possible
performance for improved maintainability.

Change-Id: I17e7d83cfc89566f76fa9949c425b950ad6aef62
31 files changed:
src/gromacs/domdec/domdec_topology.cpp
src/gromacs/fileio/checkpoint.cpp
src/gromacs/fileio/checkpoint.h
src/gromacs/fileio/tpxio.cpp
src/gromacs/gmxpreprocess/grompp.cpp
src/gromacs/imd/imd.h
src/gromacs/listed-forces/disre.h
src/gromacs/listed-forces/listed-forces.h
src/gromacs/listed-forces/orires.h
src/gromacs/mdlib/broadcaststructs.cpp
src/gromacs/mdlib/constr.h
src/gromacs/mdlib/force.cpp
src/gromacs/mdlib/force.h
src/gromacs/mdlib/md_support.cpp
src/gromacs/mdlib/md_support.h
src/gromacs/mdlib/mdrun.h
src/gromacs/mdlib/minimize.cpp
src/gromacs/mdlib/shellfc.cpp
src/gromacs/mdlib/shellfc.h
src/gromacs/mdlib/sim_util.cpp
src/gromacs/mdlib/sim_util.h
src/gromacs/mdlib/tpi.cpp
src/gromacs/mdlib/update.h
src/gromacs/mdtypes/state.cpp
src/gromacs/mdtypes/state.h
src/gromacs/pbcutil/boxutilities.h
src/gromacs/tools/dump.cpp
src/programs/mdrun/md.cpp
src/programs/mdrun/membed.h
src/programs/mdrun/repl_ex.h
src/programs/mdrun/runner.cpp