sunchao commented on a change in pull request #32507:
URL: https://github.com/apache/spark/pull/32507#discussion_r630751708



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/ApplyFunctionExpression.scala
##########
@@ -30,10 +30,11 @@ case class ApplyFunctionExpression(
   override def dataType: DataType = function.resultType()
 
   private lazy val reusedRow = new GenericInternalRow(children.size)
+  private lazy val childrenWithIndex = children.zipWithIndex
 
   /** Returns the result of evaluating this expression on a given input Row */
   override def eval(input: InternalRow): Any = {
-    children.zipWithIndex.foreach {
+    childrenWithIndex.foreach {

Review comment:
       I'm not sure if this is very useful. After the change the cost of the 
loop is negligible:
   
   <img width="806" alt="Screen Shot 2021-05-11 at 10 56 15 AM" 
src="https://user-images.githubusercontent.com/506679/117926975-6c8a7900-b2ae-11eb-9f2b-9b40f0873115.png";>
   
   Plus I think `foreach` is easier to read.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to