< prev index next >

src/java.desktop/share/classes/sun/java2d/marlin/ByteArrayCache.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 97,107 **** private final ByteArrayCache cache; Reference(final ByteArrayCache cache, final int initialSize) { this.cache = cache; this.clean = cache.clean; ! this.initial = createArray(initialSize, clean); if (DO_STATS) { cache.stats.totalInitial += initialSize; } } --- 97,107 ---- private final ByteArrayCache cache; Reference(final ByteArrayCache cache, final int initialSize) { this.cache = cache; this.clean = cache.clean; ! this.initial = createArray(initialSize); if (DO_STATS) { cache.stats.totalInitial += initialSize; } }
*** 114,124 **** } if (DO_LOG_OVERSIZE) { logInfo(getLogPrefix(clean) + "ByteArrayCache: " + "getArray[oversize]: length=\t" + length); } ! return createArray(length, clean); } byte[] widenArray(final byte[] array, final int usedSize, final int needSize) { --- 114,124 ---- } if (DO_LOG_OVERSIZE) { logInfo(getLogPrefix(clean) + "ByteArrayCache: " + "getArray[oversize]: length=\t" + length); } ! return createArray(length); } byte[] widenArray(final byte[] array, final int usedSize, final int needSize) {
*** 200,210 **** return array; } if (DO_STATS) { stats.createOp++; } ! return createArray(arraySize, clean); } void putArray(final byte[] array) { if (DO_CHECKS && (array.length != arraySize)) { --- 200,210 ---- return array; } if (DO_STATS) { stats.createOp++; } ! return createArray(arraySize); } void putArray(final byte[] array) { if (DO_CHECKS && (array.length != arraySize)) {
*** 227,242 **** + "array capacity exceeded !"); } } } ! static byte[] createArray(final int length, final boolean clean) { ! if (clean) { ! return new byte[length]; ! } ! // use JDK9 Unsafe.allocateUninitializedArray(class, length): ! return (byte[]) OffHeapArray.UNSAFE.allocateUninitializedArray(byte.class, length); } static void fill(final byte[] array, final int fromIndex, final int toIndex, final byte value) { --- 227,238 ---- + "array capacity exceeded !"); } } } ! static byte[] createArray(final int length) { ! return new byte[length]; } static void fill(final byte[] array, final int fromIndex, final int toIndex, final byte value) {
< prev index next >