JSRoyaleEmitter, MXMLRoyaleEmitter: minor optimization to avoid extra string comparisons during post-process step
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 @@
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 @@
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(")");