[WebAssembly] Don't use range-based loop for a list that's being modified