Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2019-09-04 09:41:58 +0000
committerEric Williams2019-09-10 19:25:36 +0000
commitc9fd17a7601913fa8378ef9d3885484c16b74b85 (patch)
tree8d708f9a700b75e90bde242f24c0a3def6cf2df5
parentb8b57fca96a4d74751d50520df67b5253b66e4f5 (diff)
downloadeclipse.platform.swt-c9fd17a7601913fa8378ef9d3885484c16b74b85.tar.gz
eclipse.platform.swt-c9fd17a7601913fa8378ef9d3885484c16b74b85.tar.xz
eclipse.platform.swt-c9fd17a7601913fa8378ef9d3885484c16b74b85.zip
Bug 550734 - Cache Pattern.compile in Display
Change-Id: Icb998584d2c26b5c6d6909c2e2bcd5d75646fb6b Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java15
1 files changed, 7 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index 152a7d6a7b..f6b9eb0662 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -336,6 +336,8 @@ public class Display extends Device {
/** True if the current theme is dark. This includes the theme set in GTK_THEME. */
static boolean themeDark;
+ private final static Pattern colorPattern = Pattern.compile("[^-]color: rgba?\\((\\d+(,\\s?)?){3,4}\\)");
+
/* Popup Menus */
Menu [] popups;
@@ -2146,16 +2148,13 @@ GdkRGBA gtk_css_parse_foreground (String css, String precise) {
* properties and filter out things like background-color, border-color,
* etc.
*/
- String pattern = "[^-]color: rgba?\\((\\d+(,\\s?)?){3,4}\\)";
- Pattern r = Pattern.compile(pattern);
- Matcher m = r.matcher(searched);
+
+ Matcher m = colorPattern.matcher(searched);
if (m.find()) {
String match = m.group(0);
- if (match.contains("color:")) {
- startIndex = match.indexOf("color:");
- shortOutput = match.substring(startIndex + 7);
- rgba = gtk_css_property_to_rgba(shortOutput);
- }
+ startIndex = match.indexOf("color:");
+ shortOutput = match.substring(startIndex + 7);
+ rgba = gtk_css_property_to_rgba(shortOutput);
} else {
return COLOR_WIDGET_FOREGROUND_RGBA;
}

Back to the top