Minor cleanup and (potential) optimization in compiler

Currently, the code generates calls to getCursor for every channel from 0 up to the
max channel referenced in filters/projections. With this change, the code now only
calls getCursor on channels that are actually needed for evaluation.