Skip to content

Commit

Permalink
[SQL] Minor: Avoid calling Seq#size in a loop
Browse files Browse the repository at this point in the history
Just found this instance while doing some jstack-based profiling of a Spark SQL job. It is very unlikely that this is causing much of a perf issue anywhere, but it is unnecessarily suboptimal.

Author: Aaron Davidson <[email protected]>

Closes apache#3593 from aarondav/seq-opt and squashes the following commits:

962cdfc [Aaron Davidson] [SQL] Minor: Avoid calling Seq#size in a loop
  • Loading branch information
aarondav authored and rxin committed Dec 4, 2014
1 parent 20bfea4 commit c6c7165
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ case class Coalesce(children: Seq[Expression]) extends Expression {
override def eval(input: Row): Any = {
var i = 0
var result: Any = null
while(i < children.size && result == null) {
result = children(i).eval(input)
i += 1
val childIterator = children.iterator
while (childIterator.hasNext && result == null) {
result = childIterator.next().eval(input)
}
result
}
Expand Down

0 comments on commit c6c7165

Please sign in to comment.