Hi Ulf,

Since the default method only calls a single method it will most likely be inlined.

After inlining the check will be

        if (0 < 0 || b.length < 0 || 0 > b.length - b.length) {
            throw new ArrayIndexOutOfBoundsException();
        }

Which will be optimized away so only the null check will remain.

My microbenchmark shows no difference between implementing the method or relying on the default method.

Thanks,
Staffan

On 10/17/2014 12:56 PM, Ulf Zibis wrote:
Am 17.10.2014 um 20:58 schrieb Staffan Friberg:
Here is a new webrev with the updates from Alan's and Peter's suggestions.
    http://cr.openjdk.java.net/~sfriberg/JDK-6321472/webrev.01

I would not remove:
  86     public void update(byte[] b) {
  87         adler = updateBytes(adler, b, 0, b.length);
  88     }

The interfaces default method invokes update(b, 0, b.length), which unnecessarily wastes performance with superfluous bound checks, but
  86a         if (b == null) {
  86b             throw new NullPointerException();
  86c         }
should be added, to behave same as
  71     public void update(byte[] b, int off, int len) {
in case of null array.

My 2cc.

-Ulf


Reply via email to