You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by rx...@apache.org on 2014/12/04 09:58:45 UTC
spark git commit: [SQL] Minor: Avoid calling Seq#size in a loop
Repository: spark
Updated Branches:
refs/heads/master 20bfea4ab -> c6c7165e7
[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 <aa...@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
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/c6c7165e
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/c6c7165e
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/c6c7165e
Branch: refs/heads/master
Commit: c6c7165e7ecf1690027d6bd4e0620012cd0d2310
Parents: 20bfea4
Author: Aaron Davidson <aa...@databricks.com>
Authored: Thu Dec 4 00:58:42 2014 -0800
Committer: Reynold Xin <rx...@databricks.com>
Committed: Thu Dec 4 00:58:42 2014 -0800
----------------------------------------------------------------------
.../apache/spark/sql/catalyst/expressions/nullFunctions.scala | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/c6c7165e/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/nullFunctions.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/nullFunctions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/nullFunctions.scala
index 84a3567..08b982b 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/nullFunctions.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/nullFunctions.scala
@@ -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
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org