HPCC-12408 Various code generator optimizations

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
It is here because const was added to a static variable if that condition is false, but these functions modify that variable.