Skip to content

Commit

Permalink
Removed all remaining long lines
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Jan 25, 2025
1 parent 1ff8203 commit 842651c
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/core/turbulence.Readable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,26 +89,27 @@ object Readable:
=> InType is Readable by Bytes =
channel.contramap(jn.channels.Channels.newChannel(_).nn)

given channel: Tactic[StreamError] => jn.channels.ReadableByteChannel is Readable by Bytes = channel =>
val buf: jn.ByteBuffer = jn.ByteBuffer.wrap(new Array[Byte](1024)).nn
given channel: Tactic[StreamError] => jn.channels.ReadableByteChannel is Readable by Bytes =
channel =>
val buf: jn.ByteBuffer = jn.ByteBuffer.wrap(new Array[Byte](1024)).nn

def recur(total: Long): Stream[Bytes] =
try channel.read(buf) match
case -1 => Stream().also(try channel.close() catch case err: Exception => ())
case 0 => recur(total)
def recur(total: Long): Stream[Bytes] =
try channel.read(buf) match
case -1 => Stream().also(try channel.close() catch case err: Exception => ())
case 0 => recur(total)

case count =>
buf.flip()
val size: Int = count.min(1024)
val array: Array[Byte] = new Array[Byte](size)
buf.get(array)
buf.clear()
case count =>
buf.flip()
val size: Int = count.min(1024)
val array: Array[Byte] = new Array[Byte](size)
buf.get(array)
buf.clear()

array.immutable(using Unsafe) #:: recur(total + count)
array.immutable(using Unsafe) #:: recur(total + count)

catch case e: Exception => Stream(raise(StreamError(total.b), Bytes()))
catch case e: Exception => Stream(raise(StreamError(total.b), Bytes()))

Stream.defer(recur(0))
Stream.defer(recur(0))

trait Readable:
type Self
Expand Down

0 comments on commit 842651c

Please sign in to comment.