From 4db9cb1b3286fbd54d6c2cfa065fb7ffce954f18 Mon Sep 17 00:00:00 2001 From: "samskivert@gmail.com" Date: Thu, 15 Jul 2004 23:25:54 +0000 Subject: [PATCH] Optimization in the various splices: if the operation is a no-op, just return the original array. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1466 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../java/com/samskivert/util/ArrayUtil.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/projects/samskivert/src/java/com/samskivert/util/ArrayUtil.java b/projects/samskivert/src/java/com/samskivert/util/ArrayUtil.java index 347281a4..a00aae43 100644 --- a/projects/samskivert/src/java/com/samskivert/util/ArrayUtil.java +++ b/projects/samskivert/src/java/com/samskivert/util/ArrayUtil.java @@ -392,6 +392,10 @@ public class ArrayUtil // make sure we've something to work with if (values == null) { throw new IllegalArgumentException("Can't splice a null array."); + + } else if (length == 0) { + // we're not splicing anything! + return values; } // require that the entire range to remove be within the array bounds @@ -445,6 +449,10 @@ public class ArrayUtil // make sure we've something to work with if (values == null) { throw new IllegalArgumentException("Can't splice a null array."); + + } else if (length == 0) { + // we're not splicing anything! + return values; } // require that the entire range to remove be within the array bounds @@ -498,6 +506,10 @@ public class ArrayUtil // make sure we've something to work with if (values == null) { throw new IllegalArgumentException("Can't splice a null array."); + + } else if (length == 0) { + // we're not splicing anything! + return values; } // require that the entire range to remove be within the array bounds @@ -551,6 +563,10 @@ public class ArrayUtil // make sure we've something to work with if (values == null) { throw new IllegalArgumentException("Can't splice a null array."); + + } else if (length == 0) { + // we're not splicing anything! + return values; } // require that the entire range to remove be within the array bounds @@ -605,6 +621,10 @@ public class ArrayUtil // make sure we've something to work with if (values == null) { throw new IllegalArgumentException("Can't splice a null array."); + + } else if (length == 0) { + // we're not splicing anything! + return values; } // require that the entire range to remove be within the array bounds @@ -659,6 +679,10 @@ public class ArrayUtil // make sure we've something to work with if (values == null) { throw new IllegalArgumentException("Can't splice a null array."); + + } else if (length == 0) { + // we're not splicing anything! + return values; } // require that the entire range to remove be within the array bounds