Skip to content

Commit

Permalink
Merge pull request typelevel#201 from typelevel/topic/avoid-bytebuffe…
Browse files Browse the repository at this point in the history
…r-changes

Upcast ByteBuffer before calling position(I)
  • Loading branch information
travisbrown authored Nov 7, 2019
2 parents 32d579a + ca60e87 commit 88045d3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions parser/src/main/scala/jawn/ByteBufferParser.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.typelevel.jawn

import scala.annotation.{switch, tailrec}
import java.nio.ByteBuffer
import java.nio.{ByteBuffer, Buffer}

/**
* Basic ByteBuffer parser.
Expand All @@ -24,7 +24,7 @@ final class ByteBufferParser[J](src: ByteBuffer) extends SyncParser[J] with Byte
protected[this] final def newline(i: Int): Unit = { lineState += 1; offset = i + 1 }
protected[this] final def column(i: Int) = i - offset

protected[this] final def close(): Unit = { src.position(src.limit) }
protected[this] final def close(): Unit = { (src: Buffer).position(src.limit) }
protected[this] final def reset(i: Int): Int = i
protected[this] final def checkpoint(state: Int, i: Int, context: RawFContext[J], stack: List[RawFContext[J]]): Unit = {}
protected[this] final def byte(i: Int): Byte = src.get(i + start)
Expand All @@ -33,9 +33,9 @@ final class ByteBufferParser[J](src: ByteBuffer) extends SyncParser[J] with Byte
protected[this] final def at(i: Int, k: Int): CharSequence = {
val len = k - i
val arr = new Array[Byte](len)
src.position(i + start)
(src: Buffer).position(i + start)
src.get(arr, 0, len)
src.position(start)
(src: Buffer).position(start)
new String(arr, utf8)
}

Expand Down

0 comments on commit 88045d3

Please sign in to comment.