Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f92f5f2 authored by Suprabh Shukla's avatar Suprabh Shukla Committed by android-build-merger
Browse files

Merge "Optimizing TimeSparseArray#put in case of collisions" into pi-dev

am: 7eee509d

Change-Id: I94fcc01c6a767fb21f962dd36fc2c464650cb5cb
parents add7cd04 7eee509d
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -81,13 +81,18 @@ public class TimeSparseArray<E> extends LongSparseArray<E> {
    @Override
    public void put(long key, E value) {
        final long origKey = key;
        while (indexOfKey(key) >= 0) {
        int keyIndex = indexOfKey(key);
        if (keyIndex >= 0) {
            final long sz = size();
            while (keyIndex < sz && keyAt(keyIndex) == key) {
                key++;
                keyIndex++;
            }
        if (origKey != key) {
            if (key >= origKey + 10) {
                Slog.w(TAG, "Value " + value + " supposed to be inserted at " + origKey
                        + " displaced to " + key);
            }
        }
        super.put(key, value);
    }