implementing optimization suggestions from @LeoWoerteler
see
https://github.com/JosuaKrause/JKanvas/commit/9907594ea5bf98ae17699f4dad291e40d0d1a14e#src-main-java-jkanvas-util-arrayutil-java-P85