Permalink
Browse files

Replaced unnecessary use of Array.ofDim with Array constructor to avo…

…id ClassTag lookup
  • Loading branch information...
mpilquist committed Aug 28, 2017
1 parent 6cddf8b commit 923c87d87a48001e7a45128f7184410cb9972283
@@ -147,7 +147,7 @@ private[io] object JavaInputOutputStream {
}
val sync = new SyncVar[Either[Throwable,Int]]
async.unsafeRunAsync(go(Array.ofDim(1)))(r => IO(sync.put(r)))
async.unsafeRunAsync(go(new Array[Byte](1)))(r => IO(sync.put(r)))
sync.get.fold(throw _, identity)
}
@@ -216,7 +216,7 @@ protected[tcp] object Socket {
val read = buff.position()
if (read == 0) F.pure(Chunk.bytes(Array.empty))
else {
val dest = Array.ofDim[Byte](read)
val dest = new Array[Byte](read)
buff.flip()
buff.get(dest)
F.pure(Chunk.bytes(dest))
@@ -32,7 +32,7 @@ class JavaInputOutputStreamSpec extends Fs2Spec {
stream.through(toInputStream).evalMap { is =>
// consume in same thread pool. Production application should never do this,
// instead they have to fork this to dedicated thread pool
val buff = Array.ofDim[Byte](20)
val buff = new Array[Byte](20)
@annotation.tailrec
def go(acc: Vector[Byte]): IO[Vector[Byte]] = {
is.read(buff) match {
@@ -45,7 +45,7 @@ class JavaInputOutputStreamSpec extends Fs2Spec {
example shouldBe fromInputStream
}
"upstream.is.closed" in {
var closed: Boolean = false
val s: Stream[IO, Byte] = Stream(1.toByte).onFinalize(IO(closed = true))

0 comments on commit 923c87d

Please sign in to comment.