summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin
diff options
context:
space:
mode:
authorFabian Lange <lange.fabian@gmail.com>2013-06-10 11:12:20 +0200
committerVaadin Code Review <review@vaadin.com>2013-06-12 13:37:52 +0000
commit5f66766f02b86aeda0089b8bb15da5b2c6e40715 (patch)
tree000109b5d6c2c9ffdbc01d9866ae6abb19f323c3 /server/src/com/vaadin
parenteb64fda3eb8e04e9dd5ac014981d6e7cc9683b44 (diff)
downloadvaadin-framework-5f66766f02b86aeda0089b8bb15da5b2c6e40715.tar.gz
vaadin-framework-5f66766f02b86aeda0089b8bb15da5b2c6e40715.zip
Using StringTokenizer instead of String.split() in AbstractComponent (#8759)
Avoids wasteful creation and parsing of regular expressions, which are not required here. Change-Id: I247088fbfc4eca6c2500bd6b4da9afc9d66d0a51
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r--server/src/com/vaadin/ui/AbstractComponent.java22
1 files changed, 10 insertions, 12 deletions
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java
index 772a26bda2..262d47af18 100644
--- a/server/src/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/com/vaadin/ui/AbstractComponent.java
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
+import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -176,11 +177,9 @@ public abstract class AbstractComponent extends AbstractClientConnector
}
List<String> styles = getState().styles;
styles.clear();
- String[] styleParts = style.split(" +");
- for (String part : styleParts) {
- if (part.length() > 0) {
- styles.add(part);
- }
+ StringTokenizer tokenizer = new StringTokenizer(style, " ");
+ while (tokenizer.hasMoreTokens()) {
+ styles.add(tokenizer.nextToken());
}
}
@@ -201,8 +200,9 @@ public abstract class AbstractComponent extends AbstractClientConnector
}
if (style.contains(" ")) {
// Split space separated style names and add them one by one.
- for (String realStyle : style.split(" ")) {
- addStyleName(realStyle);
+ StringTokenizer tokenizer = new StringTokenizer(style, " ");
+ while (tokenizer.hasMoreTokens()) {
+ addStyleName(tokenizer.nextToken());
}
return;
}
@@ -219,11 +219,9 @@ public abstract class AbstractComponent extends AbstractClientConnector
@Override
public void removeStyleName(String style) {
if (ComponentStateUtil.hasStyles(getState())) {
- String[] styleParts = style.split(" +");
- for (String part : styleParts) {
- if (part.length() > 0) {
- getState().styles.remove(part);
- }
+ StringTokenizer tokenizer = new StringTokenizer(style, " ");
+ while (tokenizer.hasMoreTokens()) {
+ getState().styles.remove(tokenizer.nextToken());
}
}
}