Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove redundant slicing

  • Loading branch information...
commit 6d06834ce00596f3a2b0bf44aaf527496a0a381a 1 parent ee7d813
@josharnold52 josharnold52 authored
Showing with 4 additions and 5 deletions.
  1. +4 −5 src/main/scala/com/codecommit/antixml/Zipper.scala
View
9 src/main/scala/com/codecommit/antixml/Zipper.scala
@@ -103,19 +103,18 @@ trait Zipper[+A <: Node] extends Group[A] with IndexedSeqLike[A, Zipper[A]] with
val intermedMap = map map {
case Some((from, to, rebuild, childMap)) => {
val childMapSorted = (childMap.toSeq) sortWith { _._1 < _._1 } //TODO - Maybe just make childMap a SortedMap
- val localResults = result.slice(from,to)
-
- val (_, chunk, childMap2) = ((0, Vector[B](), Map[Int,Int]()) /: childMapSorted) {
+ val (lastOffset, chunk, childMap2) = ((from, Vector[B](), Map[Int,Int]()) /: childMapSorted) {
case ((offset, acc, childMap2),(srcIndex, 0)) =>
(offset, acc, childMap2 + (srcIndex -> 0))
case ((offset, acc, childMap2),(srcIndex,destCount)) => {
- val items = localResults.slice(offset, offset+destCount).flatMap {x => x}
+ val items = result.slice(offset, offset+destCount).flatMap(identity)
(offset + destCount, acc ++ items, childMap2 + (srcIndex -> items.size))
}
}
-
+ assert(lastOffset == to)
+
Some(chunk, rebuild, childMap2)
}
Please sign in to comment.
Something went wrong with that request. Please try again.