Skip to content

Commit

Permalink
Avoid {List,Array}Buffer.append
Browse files Browse the repository at this point in the history
  • Loading branch information
fosskers authored and echeipesh committed Jan 3, 2018
1 parent 9c354f1 commit 6c41ef6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ object R2Viewshed extends Serializable {
val seg = northSegs(i)
alpha = thetaToAlpha(from, rays, seg.theta); terminated = false
Rasterizer.foreachCellInGridLine(seg.x0, seg.y0, seg.x1, seg.y1, null, re, false)(callback)
if (!terminated && !seg.isRumpSegment) southRays.append(Ray(seg.theta, alpha))
if (!terminated && !seg.isRumpSegment) (southRays += Ray(seg.theta, alpha))
i += 1
}

Expand All @@ -358,7 +358,7 @@ object R2Viewshed extends Serializable {
val seg = southSegs(i)
alpha = thetaToAlpha(from, rays, seg.theta); terminated = false
Rasterizer.foreachCellInGridLine(seg.x0, seg.y0, seg.x1, seg.y1, null, re, false)(callback)
if (!terminated && !seg.isRumpSegment) northRays.append(Ray(seg.theta, alpha))
if (!terminated && !seg.isRumpSegment) (northRays += Ray(seg.theta, alpha))
i += 1
}

Expand All @@ -377,7 +377,7 @@ object R2Viewshed extends Serializable {
val seg = eastSegs(i)
alpha = thetaToAlpha(from, rays, seg.theta); terminated = false
Rasterizer.foreachCellInGridLine(seg.x0, seg.y0, seg.x1, seg.y1, null, re, false)(callback)
if (!terminated && !seg.isRumpSegment) westRays.append(Ray(seg.theta, alpha))
if (!terminated && !seg.isRumpSegment) (westRays += Ray(seg.theta, alpha))
i += 1
}
}
Expand All @@ -397,7 +397,7 @@ object R2Viewshed extends Serializable {
val seg = westSegs(i)
alpha = thetaToAlpha(from, rays, seg.theta); terminated = false
Rasterizer.foreachCellInGridLine(seg.x0, seg.y0, seg.x1, seg.y1, null, re, false)(callback)
if (!terminated && !seg.isRumpSegment) eastRays.append(Ray(seg.theta, alpha))
if (!terminated && !seg.isRumpSegment) (eastRays += Ray(seg.theta, alpha))
i += 1
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ object IterativeCostDistance {
other
}
def add(pair: KeyCostPair): Unit = {
this.synchronized { list.append(pair) }
this.synchronized { list += pair }
}
def isZero: Boolean = list.isEmpty
def merge(other: AccumulatorV2[KeyCostPair, Changes]): Unit =
Expand Down Expand Up @@ -96,7 +96,7 @@ object IterativeCostDistance {

var row = bounds.rowMin; while (row <= bounds.rowMax) {
var col = bounds.colMin; while (col <= bounds.colMax) {
keys.append(SpatialKey(col, row))
keys += SpatialKey(col, row)
col += 1
}
row += 1
Expand Down
6 changes: 3 additions & 3 deletions vectortile/src/main/scala/geotrellis/vectortile/Layer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ ${sortedMeta.map({ case (k,v) => s" ${k}: ${v}"}).mkString("\n")}

features.foreach { f =>
f.getType match {
case POINT => points.append(f)
case LINESTRING => lines.append(f)
case POLYGON => polys.append(f)
case POINT => points += f
case LINESTRING => lines += f
case POLYGON => polys += f
case _ => Unit // `UNKNOWN` or `Unrecognized`.
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ package object internal {
case (dx, dy) =>
val here = (dx + cursor._1, dy + cursor._2)

points.append(here)
points += here
cursor = here
})

Expand Down Expand Up @@ -252,7 +252,7 @@ package object internal {
val nextCursor: (Int, Int) = points.last

/* Add the starting point to close the Line into a Polygon */
points.append(here)
points += here

work(rest, lines += points, nextCursor)
}
Expand Down Expand Up @@ -280,10 +280,10 @@ package object internal {
val area = surveyor(line)

if (area < 0) { /* New Interior Rings */
holes.append(tr(line))
holes += tr(line)
} else { /* New Exterior Ring */
/* Save the current state */
polys.append(Polygon(tr(currL), holes))
polys += Polygon(tr(currL), holes)

/* Reset the state */
currL = line
Expand All @@ -292,7 +292,7 @@ package object internal {
})

/* Save the final state */
polys.append(Polygon(tr(currL), holes))
polys += Polygon(tr(currL), holes)

if (polys.length == 1) Left(polys.head) else Right(MultiPolygon(polys))
}
Expand Down

0 comments on commit 6c41ef6

Please sign in to comment.