From c9fd17a7601913fa8378ef9d3885484c16b74b85 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Wed, 4 Sep 2019 11:41:58 +0200 Subject: Bug 550734 - Cache Pattern.compile in Display Change-Id: Icb998584d2c26b5c6d6909c2e2bcd5d75646fb6b Signed-off-by: Lars Vogel --- .../Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java | 15 +++++++-------- 1 file 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; } -- cgit v1.2.3