Skip to content

Commit

Permalink
fix some warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
az4521 committed Mar 31, 2024
1 parent fea4c5d commit 9d1b1ae
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions app/src/main/java/exh/util/FakeMutables.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package exh.util

// Zero-allocation-overhead mutable collection shims

private inline class CollectionShim<E>(private val coll: Collection<E>) : FakeMutableCollection<E> {
@JvmInline
private value class CollectionShim<E>(private val coll: Collection<E>) : FakeMutableCollection<E> {
override val size: Int get() = coll.size

override fun contains(element: E) = coll.contains(element)
Expand Down Expand Up @@ -46,7 +47,8 @@ interface FakeMutableCollection<E> : MutableCollection<E>, FakeMutableIterable<E
}
}

private inline class SetShim<E>(private val set: Set<E>) : FakeMutableSet<E> {
@JvmInline
private value class SetShim<E>(private val set: Set<E>) : FakeMutableSet<E> {
override val size: Int get() = set.size

override fun contains(element: E) = set.contains(element)
Expand Down Expand Up @@ -83,7 +85,8 @@ interface FakeMutableSet<E> : MutableSet<E>, FakeMutableCollection<E> {
}
}

private inline class IterableShim<E>(private val iterable: Iterable<E>) : FakeMutableIterable<E> {
@JvmInline
private value class IterableShim<E>(private val iterable: Iterable<E>) : FakeMutableIterable<E> {
override fun fakeIterator() = iterable.iterator()
}

Expand All @@ -100,7 +103,8 @@ interface FakeMutableIterable<E> : MutableIterable<E> {
}
}

private inline class IteratorShim<E>(private val iterator: Iterator<E>) : FakeMutableIterator<E> {
@JvmInline
private value class IteratorShim<E>(private val iterator: Iterator<E>) : FakeMutableIterator<E> {
/**
* Returns `true` if the iteration has more elements.
*/
Expand All @@ -125,7 +129,8 @@ interface FakeMutableIterator<E> : MutableIterator<E> {
}
}

private inline class EntryShim<K, V>(private val entry: Map.Entry<K, V>) : FakeMutableEntry<K, V> {
@JvmInline
private value class EntryShim<K, V>(private val entry: Map.Entry<K, V>) : FakeMutableEntry<K, V> {
/**
* Returns the key of this key/value pair.
*/
Expand All @@ -138,7 +143,8 @@ private inline class EntryShim<K, V>(private val entry: Map.Entry<K, V>) : FakeM
get() = entry.value
}

private inline class PairShim<K, V>(private val pair: Pair<K, V>) : FakeMutableEntry<K, V> {
@JvmInline
private value class PairShim<K, V>(private val pair: Pair<K, V>) : FakeMutableEntry<K, V> {
/**
* Returns the key of this key/value pair.
*/
Expand Down

0 comments on commit 9d1b1ae

Please sign in to comment.