Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Barnes2006-03-17 16:34:14 -0500
committerKevin Barnes2006-03-17 16:34:14 -0500
commit0333874414126dba03539b0cd8d0017025ad832a (patch)
tree8ad2b6742c211fe0336323d76d639436a3884474 /org.eclipse.ui.console
parentba3b9df9e88d513372b5883965066c42cf545d72 (diff)
downloadeclipse.platform.debug-0333874414126dba03539b0cd8d0017025ad832a.tar.gz
eclipse.platform.debug-0333874414126dba03539b0cd8d0017025ad832a.tar.xz
eclipse.platform.debug-0333874414126dba03539b0cd8d0017025ad832a.zip
Bug 132398 - Console Performance Test failures on fast windows box
Diffstat (limited to 'org.eclipse.ui.console')
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java78
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java7
2 files changed, 39 insertions, 46 deletions
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java
index e54fba468..3e20d5d0b 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleDocumentAdapter.java
@@ -13,8 +13,6 @@ package org.eclipse.ui.internal.console;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.BadLocationException;
@@ -45,8 +43,6 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen
int[] lengths = new int[5000];
private int regionCount = 0;
- private Pattern pattern = Pattern.compile("^.*$", Pattern.MULTILINE); //$NON-NLS-1$
-
public ConsoleDocumentAdapter(int width) {
textChangeListeners = new ArrayList();
@@ -124,22 +120,6 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen
regionCount++;
}
- /**
- * Returns <code>true</code> if the line ends with a legal line delimiter
- *
- * @return <code>true</code> if the line ends with a legal line delimiter,
- * <code>false</code> otherwise
- */
- private boolean lineEndsWithDelimeter(String line) {
- String[] lld = document.getLegalLineDelimiters();
- for (int i = 0; i < lld.length; i++) {
- if (line.endsWith(lld[i])) {
- return true;
- }
- }
- return false;
- }
-
/* (non-Javadoc)
* @see org.eclipse.jface.text.IDocumentAdapter#setDocument(org.eclipse.jface.text.IDocument)
*/
@@ -328,29 +308,41 @@ public class ConsoleDocumentAdapter implements IDocumentAdapter, IDocumentListen
* display the String
* @return The number of lines necessary to display the string in the viewer.
*/
- private int countLines(String string) {
- int count = 0;
- if (lineEndsWithDelimeter(string)) {
- count++;
- }
-
-// work around to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4994840
-// see bug 84641
- if (string.endsWith("\r")) { //$NON-NLS-1$
- int len = string.length();
- int index = len >= 2 ? len-2 : 0;
- string = string.substring(0, index);
- }
-
- Matcher matcher = pattern.matcher(string);
- while (matcher.find()) {
- count++;
- if (consoleWidth > 0) {
- String line = matcher.group();
- count += (line.length() / consoleWidth);
- }
- }
- return count;
+ private int countLines(String line) {
+ int count = 0;
+
+ int lastDelimiter = 0;
+ for (int i = 0; i < line.length(); i++) {
+ char c = line.charAt(i);
+ if (c == '\n') {
+ count++;
+ if (consoleWidth > 0) {
+ count += (i-lastDelimiter)/consoleWidth;
+ }
+ lastDelimiter = i;
+ } else if (c == '\r') {
+ count++;
+ if (consoleWidth > 0) {
+ count += (i-lastDelimiter)/consoleWidth;
+ }
+ if (i+1 < line.length()) {
+ char next = line.charAt(i+1);
+ if (next == '\n') {
+ i++;
+ }
+ }
+ lastDelimiter = i;
+ }
+ }
+
+ if (lastDelimiter < line.length()) {
+ count++;
+ if (consoleWidth > 0) {
+ count += (line.length()-lastDelimiter)/consoleWidth;
+ }
+ }
+
+ return count;
}
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
index 2d2867c0c..adb8954e3 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
@@ -35,6 +35,7 @@ import org.eclipse.ui.console.IConsoleDocumentPartitioner;
import org.eclipse.ui.console.IOConsole;
import org.eclipse.ui.console.IOConsoleInputStream;
import org.eclipse.ui.console.IOConsoleOutputStream;
+import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.progress.WorkbenchJob;
/**
@@ -454,10 +455,10 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum
last.append(s);
} else {
pendingPartitions.add(new PendingPartition(stream, s));
- if (fBuffer > 10000) {
+ if (fBuffer > 1000) {
queueJob.schedule();
} else {
- queueJob.schedule(150);
+ queueJob.schedule(50);
}
}
@@ -494,7 +495,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum
* Updates the document. Will append everything that is available before
* finishing.
*/
- private class QueueProcessingJob extends WorkbenchJob {
+ private class QueueProcessingJob extends UIJob {
QueueProcessingJob() {
super("IOConsole Updater"); //$NON-NLS-1$

Back to the top