Skip to content
Snippets Groups Projects
Commit c6c7165e authored by Aaron Davidson's avatar Aaron Davidson Committed by Reynold Xin
Browse files

[SQL] Minor: Avoid calling Seq#size in a loop

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 <aaron@databricks.com>

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

962cdfc [Aaron Davidson] [SQL] Minor: Avoid calling Seq#size in a loop
parent 20bfea4a
No related branches found
No related tags found
No related merge requests found
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment