issue #3935 Refactor some functions about array operation.

issue #3935 Refactor some functions about array operation.