Skylark interpreter optimization

Special-case the return statement to avoid throwing an exception.

--
MOS_MIGRATED_REVID=106488391
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java b/src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java
index 88b5c4b..df0c197 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/UserDefinedFunction.java
@@ -73,7 +73,13 @@
 
       try {
         for (Statement stmt : statements) {
-          stmt.exec(env);
+          if (stmt instanceof ReturnStatement) {
+            // Performance optimization.
+            // Executing the statement would throw an exception, which is slow.
+            return ((ReturnStatement) stmt).getReturnExpression().eval(env);
+          } else {
+            stmt.exec(env);
+          }
         }
       } catch (ReturnStatement.ReturnException e) {
         return e.getValue();