Loading core/java/com/android/internal/util/RingBuffer.java +14 −9 Original line number Diff line number Diff line Loading @@ -67,16 +67,21 @@ public class RingBuffer<T> { */ public T getNextSlot() { final int nextSlotIdx = indexOf(mCursor++); T item = mBuffer[nextSlotIdx]; if (item == null) { if (mBuffer[nextSlotIdx] == null) { mBuffer[nextSlotIdx] = createNewItem(); } return mBuffer[nextSlotIdx]; } /** * @return a new object of type <T> or null if a new object could not be created. */ protected T createNewItem() { try { item = (T) mBuffer.getClass().getComponentType().newInstance(); return (T) mBuffer.getClass().getComponentType().newInstance(); } catch (IllegalAccessException | InstantiationException e) { return null; } mBuffer[nextSlotIdx] = item; } return item; } public T[] toArray() { Loading Loading
core/java/com/android/internal/util/RingBuffer.java +14 −9 Original line number Diff line number Diff line Loading @@ -67,16 +67,21 @@ public class RingBuffer<T> { */ public T getNextSlot() { final int nextSlotIdx = indexOf(mCursor++); T item = mBuffer[nextSlotIdx]; if (item == null) { if (mBuffer[nextSlotIdx] == null) { mBuffer[nextSlotIdx] = createNewItem(); } return mBuffer[nextSlotIdx]; } /** * @return a new object of type <T> or null if a new object could not be created. */ protected T createNewItem() { try { item = (T) mBuffer.getClass().getComponentType().newInstance(); return (T) mBuffer.getClass().getComponentType().newInstance(); } catch (IllegalAccessException | InstantiationException e) { return null; } mBuffer[nextSlotIdx] = item; } return item; } public T[] toArray() { Loading