Use shallow clone while expanding definitions

When walking ancestors, a lot more node refreshing is done. Refreshing
nodes often involves expanding the task definitions which involves
copying the original definition. Reduce the time spent doing these
copies drastically by using a shallow clone instead of the previous deep
copy. This has been safe to do for some time because of the COW policy
which is being used during expansion and preloading. Additionally,
accidental overwrites have also been safeguarded against for some time
now by using unmodifiable collections in the definitions, and this
change adds two additional redudant safeguards. To be consistent and to
prevent future issues with NamesFactories, use a shallow clone for them
also.

The performance difference in the case of a task.config which walks all
dependencies for a change when run with status:open --no-limit
--task--applicable is about 1/3 faster:

Before this change: 24m13s 24m36s 22m48s 23m36s 24m22s
After this change:  15m14s 15m46s 17m37s 15m24s 15m11s

Change-Id: I2f78b42c1fa68f2751ac04e26f6ec4d5989db585
4 files changed