ClearMatches: Only clear matches which were actually set

ClearMatches was clearing many variables which were never set in the
first place. Instead, store how many matches were made last time and
only clear those. It is moved to the cmMakefile class since it is a
common utility used by multiple commands.
ClearMatches: Store match variable names statically

Constructing the names and then turning them into a std::string is
non-negligible in performance testing.
StoreMatches: Minor cleanups
Merge topic 'dev/regex-variables' into next

3f517522 StoreMatches: Minor cleanups
ef62fbad ClearMatches: Store match variable names statically
f718b30a ClearMatches: Only clear matches which were actually set