]> https://gitweb.dealii.org/ - dealii.git/commit
Clean up some code in AffineConstraints::is_consistent_in_parallel. 6923/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Sun, 15 Jul 2018 10:55:27 +0000 (04:55 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sun, 15 Jul 2018 10:55:27 +0000 (04:55 -0600)
commitaf8de1503c1a17253e9e8b826fbd072ba57dbe24
treed5c280f0b5fd07522c9d7b227a8ec508b2200d5f
parent92527de0805b3a010731a07c467ee0917d5aceed
Clean up some code in AffineConstraints::is_consistent_in_parallel.

The existing code has a lambda function that either returns a reference to
an existing element of a vector, or to a dummy member variable. But to
make things confusing, it *modifies* this dummy variable, which means that
what looks like some 'const' dummy object is not actually.

All of this is done to avoid copies, but in reality a copy is still
made at a later point where we insert the result of this lambda
function into a vector. This patch cleans this up by removing the
non-const dummy variable and instead just returning a copy that is
then moved into the vector. That's the same number of copies as before,
in most cases, and it's clearer to read because there is no more
potential for two parts of the code stepping on each others' toes
modifying the dummy variable.

These things are important to me because modifying the dummy variable
is a sure way to introduce really hard to find errors if anyone ever
wanted to multi-thread this function. It's not likely that anyone
will try this for this function soon, except possibly by using
things like parallel-for loops should they ever become available.
But it's worth not even getting into the habit of using this style.
include/deal.II/lac/affine_constraints.templates.h

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.