This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 490a0a5cfcf40cde55e6f780b9135b7494d8aa9c
Author: Josh Tynjala <joshtynj...@apache.org>
AuthorDate: Thu Jun 27 09:42:03 2019 -0700

    JSRoyaleEmitter, MXMLRoyaleEmitter: minor optimization to avoid extra 
string comparisons during post-process step
---
 .../internal/codegen/js/royale/JSRoyaleEmitter.java       | 15 +++++++++------
 .../internal/codegen/mxml/royale/MXMLRoyaleEmitter.java   | 15 +++++++++------
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
index 9523f29..a5f43e6 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
@@ -181,14 +181,17 @@ public class JSRoyaleEmitter extends JSGoogEmitter 
implements IJSRoyaleEmitter
             String line = lines[i];
                if (stillSearching)
                {
-                int c = 
line.indexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
-                if (c != -1)
+                if (provideIndex == -1 || !sawRequires)
                 {
-                    // if zero requires are found, require Language after the
-                    // call to goog.provide
-                    provideIndex = addIndex = i + 1;
+                    int c = 
line.indexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
+                    if (c != -1)
+                    {
+                        // if zero requires are found, require Language after 
the
+                        // call to goog.provide
+                        provideIndex = addIndex = i + 1;
+                    }
                 }
-                   c = 
line.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+                   int c = 
line.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
                    if (c != -1)
                    {
                     // we found other requires, so we'll just add Language at
diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
index 9abdddf..826f44e 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
@@ -206,14 +206,17 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
             String line = lines[i];
                if (stillSearching)
                {
-                int c = 
line.indexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
-                if (c != -1)
+                if (provideIndex == -1 || !sawRequires)
                 {
-                    // if zero requires are found, require Language after the
-                    // call to goog.provide
-                    provideIndex = i + 1;
+                    int c = 
line.indexOf(JSGoogEmitterTokens.GOOG_PROVIDE.getToken());
+                    if (c != -1)
+                    {
+                        // if zero requires are found, require Language after 
the
+                        // call to goog.provide
+                        provideIndex = i + 1;
+                    }
                 }
-                   c = 
line.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
+                   int c = 
line.indexOf(JSGoogEmitterTokens.GOOG_REQUIRE.getToken());
                    if (c > -1)
                    {
                        int c2 = line.indexOf(")");

Reply via email to