itemAtIndex (and to a slightly lesser extent) arrayLength just seem to be getting in the way here. Expand them inline, and lose the for loop and index bounds asserts with a foolproof BOOST_FOREACH over the vector  -- with a (const NValue& value variable to avoid yet more temp NValue copies.