simerplaha / SwayDB

Persistent and in-memory key-value storage engine for JVM that scales on a single machine.

Home Page:https://swaydb.simer.au

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Switch `Slice(1,2, ...)` API to create `new Array` without deferring

simerplaha opened this issue · comments

commented

These functions in CompanionSlice should create new Array directly to remove input type-check performed by scala.Array(a, b, c ... )

@inline final def apply[T: ClassTag](a: T, b: T, c: T): Slice[T] = Slice.wrap(Array(a, b, c))
@inline final def apply[T: ClassTag](a: T, b: T, c: T, d: T): Slice[T] = Slice.wrap(Array(a, b, c, d))
...

For example

@inline final def apply[T: ClassTag](a: T, b: T, c: T): Slice[T] = {
  val array = new Array[T](3)
  array(0) = a
  array(1) = b
  array(2) = c
  Slice.wrap(array)
}