[cs] optimize fields interation in generic casting (same as 5641834de3ad00ad5c228fe2dfd844a85c9f4c6d)