lib: improved forEach object performance

Reviewed-by: Trevor Norris <trev.norris@gmail.com>