Avoid unnecessary copies for DynamicType::GetObjects.

Fixes #5987