improved ArrayImpl performance - solved ticket 2869

this is for branch 4.2, but IMO these fixes are important enough to go into 4.1 as well.
see https://issues.jboss.org/browse/RAILO-2869