ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r677887 - in /ant/core/trunk: CONTRIBUTORS contributors.xml src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java
Date Fri, 18 Jul 2008 12:37:35 GMT
Author: bodewig
Date: Fri Jul 18 05:37:34 2008
New Revision: 677887

URL: http://svn.apache.org/viewvc?rev=677887&view=rev
Log:
avoid excessive StringBuffer.toString calls while waiting for a response string.  PR 34464.
 Based on patch by Adam Blinkinsop.

Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/contributors.xml
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java

Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=677887&r1=677886&r2=677887&view=diff
==============================================================================
Binary files - no diff available.

Modified: ant/core/trunk/contributors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=677887&r1=677886&r2=677887&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Fri Jul 18 05:37:34 2008
@@ -31,6 +31,10 @@
   These are some of the many people who have helped Ant become so successful.
   </introduction>
   <name>
+    <first>Adam</first>
+    <last>Blinkinsop</last>
+  </name>
+  <name>
     <first>Aleksandr</first>
     <last>Ishutin</last>
   </name>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java?rev=677887&r1=677886&r2=677887&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/RExecTask.java Fri
Jul 18 05:37:34 2008
@@ -203,14 +203,17 @@
             InputStream is = this.getInputStream();
             try {
                 StringBuffer sb = new StringBuffer();
+                int windowStart = -s.length();
                 if (timeout == null || timeout.intValue() == 0) {
-                    while (sb.toString().indexOf(s) == -1) {
+                    while (windowStart++ < 0
+                           || !sb.substring(windowStart).equals(s)) {
                         sb.append((char) is.read());
                     }
                 } else {
                     Calendar endTime = Calendar.getInstance();
                     endTime.add(Calendar.SECOND, timeout.intValue());
-                    while (sb.toString().indexOf(s) == -1) {
+                    while (windowStart++ < 0
+                           || !sb.substring(windowStart).equals(s)) {
                         while (Calendar.getInstance().before(endTime)
                             && is.available() == 0) {
                             Thread.sleep(PAUSE_TIME);

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java?rev=677887&r1=677886&r2=677887&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/net/TelnetTask.java Fri
Jul 18 05:37:34 2008
@@ -340,14 +340,17 @@
             InputStream is = this.getInputStream();
             try {
                 StringBuffer sb = new StringBuffer();
+                int windowStart = -s.length();
                 if (timeout == null || timeout.intValue() == 0) {
-                    while (sb.toString().indexOf(s) == -1) {
+                    while (windowStart++ < 0
+                           || !sb.substring(windowStart).equals(s)) {
                         sb.append((char) is.read());
                     }
                 } else {
                     Calendar endTime = Calendar.getInstance();
                     endTime.add(Calendar.SECOND, timeout.intValue());
-                    while (sb.toString().indexOf(s) == -1) {
+                    while (windowStart++ < 0
+                           || !sb.substring(windowStart).equals(s)) {
                         while (Calendar.getInstance().before(endTime)
                                && is.available() == 0) {
                             Thread.sleep(WAIT_INTERVAL);



Mime
View raw message