Permalink
Browse files

fix benchmark dependencies

  • Loading branch information...
1 parent 6404e92 commit 864e26af07b96bc5b9765f895b4d35b3cc6f26af @arjanblokzijl committed May 4, 2012
@@ -5,6 +5,7 @@ import empty.Void
import scalaz._
import CL._
import binary._
+import bs._
import Conduits._
object BinaryBenchmark extends MyRunner { val cls = classOf[BinaryBenchmark]}
@@ -88,15 +88,19 @@ sealed trait LByteString {
if (sb.length < 64) Chunk(b &: sb, lb) else Chunk(ByteString.singleton(b), lb)
)
- def append(ys: => LByteString): LByteString = fold(empty = ys, chunk = (sb, lb) =>
- Chunk(sb, lb append ys)
- )
+ /**Appends two lazy bytestrings.*/
+ def append(ys: => LByteString): LByteString = this match {
+ case Empty() => ys
+ case Chunk(b, bs) => Chunk(b, bs append ys)
+ }
+ /**Splits the bytestring into its head and tail. Returns None if the Bytestring is empty.*/
def uncons: Option[(Byte, LByteString)] = this match {
case Empty() => None
case Chunk(c, cs) => Some(c.head, if (c.length == 1) cs else Chunk(c.tail, cs))
}
+ /**Takes part of the bytestring while the conditional is true.*/
def takeWhile(p: Byte => Boolean): LByteString = this match {
case Empty() => Empty.apply
case Chunk(c, cs) => {
@@ -107,6 +111,7 @@ sealed trait LByteString {
}
}
+ /**Drops part of the bytestring while the conditional is true.*/
def dropWhile(p: Byte => Boolean): LByteString = this match {
case Empty() => Empty.apply
case Chunk(c, cs) => {
@@ -116,6 +121,7 @@ sealed trait LByteString {
}
}
+ /**Gets the byte at the specified index.*/
def apply(idx: Int): Byte = this match {
case Empty() => sys.error("apply on empty LByteString")
case Chunk(c, cs) =>
@@ -128,6 +134,7 @@ sealed trait LByteString {
case Chunk(c, cs) => c.length + cs.length
}
+ /**Applies the provided function to each Byte in the bytestring.*/
def map(f: Byte => Byte): LByteString = this match {
case Empty() => Empty.apply
case Chunk(c, cs) => Chunk(ByteString.fromSeq(c map f), cs map f)
@@ -45,5 +45,9 @@ class LByteStringSpec extends Specification with ScalaCheck {
val s = Stream.from(1).map(_.toByte)
LByteString.pack(s).take(20).unpack must be_==(s.take(20))
}
+ "handle map lazy" in {
+ val s = Stream.from(1).map(_.toByte)
+ LByteString.pack(s).map(b => (b + 1).toByte).take(20).unpack must be_==(s.map(b => (b + 1).toByte).take(20))
+ }
}
}
View
@@ -8,7 +8,7 @@ object ScalaConduitsBuild extends Build {
id = "scala-conduits",
base = file("."),
settings = standardSettings,
- aggregate = Seq(resourcet, bytestring, text, conduits, examples, benchmark)
+ aggregate = Seq(resourcet, bytestring, text, conduits, parse, examples, benchmark)
)
lazy val conduits = Project(
@@ -65,7 +65,7 @@ object ScalaConduitsBuild extends Build {
lazy val benchmark: Project = Project(
id = "benchmark",
base = file("benchmark"),
- dependencies = Seq[ClasspathDep[ProjectReference]](conduits),
+ dependencies = Seq[ClasspathDep[ProjectReference]](conduits, bytestring, text),
settings = benchmarkSettings
)

0 comments on commit 864e26a

Please sign in to comment.