Use expanded task if refreshing is not required

When reusing defintions, use an already expanded one (and inform the
Properties class of this so that it no longer expands it) whenever the
task expansion results in a definition which does not depend on external
factors and thus would always be the same anyway. Since definitions are
mostly only reused for ChangeNodes, this is most effective when walking
changes.

In a sample walking ancestors use case, this caching and saves a small
but measurable amount of the total time. In the case of a task.config
which walks all dependencies for a change when run with status:open
--no-limit --task--applicable the gain can be seen below.

Before this change: 3m37s 3m34s 4m6s 6m23s 3m42s
After this change:  8m7s 3m16s 3m26s 3m16s 3m21s

Change-Id: I5892519583bc1b34fb9625b8b095e0af6d10c44f
1 file changed