Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
simerplaha opened this issue Aug 14, 2022 · 0 comments
Open

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

simerplaha opened this issue Aug 14, 2022 · 0 comments
Labels
code cleanup Tasks that require general code improvements to improve readability good first issue Good for newcomers performance

Comments

@simerplaha
Copy link
Owner

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)
}
@simerplaha simerplaha added good first issue Good for newcomers code cleanup Tasks that require general code improvements to improve readability performance labels Aug 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code cleanup Tasks that require general code improvements to improve readability good first issue Good for newcomers performance
Projects
None yet
Development

No branches or pull requests

1 participant