HPCC-12408 Various code generator optimizations

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
HPCC-12408 Changes following code review

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
HPCC-12408 Clarify comment (in pre-existing code).

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Merge pull request #6536 from ghalliday/issue12408

HPCC-12408 Various code generator optimizations

Reviewed-By: Jamie Noss <james.noss@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>