Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzeljko.zurzic2019-04-22 05:11:47 -0400
committerAndrey Loskutov2019-04-23 08:55:31 -0400
commit54ad465f841c2c09437070d0234d1e3166301b89 (patch)
tree46ab9800da515fff53bf46bd1ac97c0a741e2935
parent07d217568ed42667a08d1c1460c8d4c364a9d361 (diff)
downloadeclipse.platform.text-54ad465f841c2c09437070d0234d1e3166301b89.tar.gz
eclipse.platform.text-54ad465f841c2c09437070d0234d1e3166301b89.tar.xz
eclipse.platform.text-54ad465f841c2c09437070d0234d1e3166301b89.zip
Changes the line tracker used for DocumentClone. If the line delimiters are equal to the default ones, use the DefaultLineTracker instead of the ConfigurableLineTracker - for performance improvement Change-Id: I9b6b570d87eade205f4984f04001ec8170f09c3e Signed-off-by: zeljko.zurzic <zeljko.zurzic@amiq.com> Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentClone.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentClone.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentClone.java
index ca3d3b4cd..84493304b 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentClone.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentClone.java
@@ -71,7 +71,19 @@ class DocumentClone extends AbstractDocument {
public DocumentClone(String content, String[] lineDelimiters) {
super();
setTextStore(new StringTextStore(content));
- ConfigurableLineTracker tracker= new ConfigurableLineTracker(lineDelimiters);
+
+ boolean hasDefaultDelims= lineDelimiters == null;
+ if (!hasDefaultDelims && DefaultLineTracker.DELIMITERS.length == lineDelimiters.length) {
+ hasDefaultDelims= true;
+ for (int i= 0; i < lineDelimiters.length; i++) {
+ if (DefaultLineTracker.DELIMITERS[i] != lineDelimiters[i]) {
+ hasDefaultDelims= false;
+ break;
+ }
+ }
+ }
+
+ ILineTracker tracker= hasDefaultDelims ? new DefaultLineTracker() : new ConfigurableLineTracker(lineDelimiters);
setLineTracker(tracker);
getTracker().set(content);
completeInitialization();

Back to the top