8000 Fix #1115: Enrich js.WrappedArray with Buffer and BufferLike. by sjrd · Pull Request #1119 · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content

Fix #1115: Enrich js.WrappedArray with Buffer and BufferLike. #1119

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&rd 8000 quo;, 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

Merged
merged 5 commits into from
Sep 26, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Specialize genTraversableOnce2jsArray for js.ArrayOps and js.WrappedA…
…rray.

In a sense, this is as if .toJSArray were overridden in js.ArrayOps
and js.WrappedArray, which makes total sense. But since .toJSArray
is a pimp, we need to make this specialization directly in its
implementation.
  • Loading branch information
sjrd committed Sep 26, 2014
commit 2b5dc7218152e428072bd08547de57b54b78e70c
11 changes: 8 additions & 3 deletions library/src/main/scala/scala/scalajs/runtime/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ package object runtime {

@inline final def genTraversableOnce2jsArray[A](
col: GenTraversableOnce[A]): js.Array[A] = {
val result = new js.Array[A]
col.foreach(x => result.push(x))
result
col match {
case col: js.ArrayOps[A] => col.result()
case col: js.WrappedArray[A] => col.array
case _ =>
val result = new js.Array[A]
col.foreach(x => result.push(x))
result
}
}

/** Information about the environment Scala.js runs in. */
Expand Down
0