Skip to content

Commit

Permalink
Use expression bodies instead of return statements
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrepiveteau committed Apr 25, 2023
1 parent f9041be commit ebc9b31
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@ package io.github.alexandrepiveteau.graphs.util

/** Packs two [Int] values into one [Long] value for use in inline classes. */
@PublishedApi
internal inline fun packInts(val1: Int, val2: Int): Long {
return val1.toLong().shl(32) or (val2.toLong() and 0xFFFFFFFF)
}
internal inline fun packInts(
val1: Int,
val2: Int,
): Long = val1.toLong().shl(32) or (val2.toLong() and 0xFFFFFFFF)

/** Unpacks the first [Int] value in [packInts] from its returned [Long]. */
@PublishedApi
internal inline fun unpackInt1(value: Long): Int {
return value.shr(32).toInt()
}
@PublishedApi internal inline fun unpackInt1(value: Long): Int = value.shr(32).toInt()

/** Unpacks the second [Int] value in [packInts] from its returned [Long]. */
@PublishedApi
internal inline fun unpackInt2(value: Long): Int {
return value.and(0xFFFFFFFF).toInt()
}
@PublishedApi internal inline fun unpackInt2(value: Long): Int = value.and(0xFFFFFFFF).toInt()

0 comments on commit ebc9b31

Please sign in to comment.