(#16089) Reduce scope lookups in parse_string

Slightly modified version of patch from Jeff Goldschrafe (see
https://projects.puppetlabs.com/issues/16089). This version only optimizes the
lookup to the main scope, since this appears to be the only used code path.
This version only optimizes the lookup to the main scope, since this appears
to be the only used code path. This version only optimizes the lookup to the
main scope, since this appears to be the only used code path. This version
only optimizes the lookup to the main scope, since this appears to be the only
used code path.