Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Ufimtsev2018-05-29 17:06:32 +0000
committerLeo Ufimtsev2018-05-29 19:09:44 +0000
commit65ddc8a5374963e50f794bf6b3b36d84dd19105d (patch)
tree24fbb94106527782111720cd6f129981140c2578 /bundles/org.eclipse.swt/Eclipse SWT PI
parent2bd7cc57d6f8db85984adca7abc84236618f0b2d (diff)
downloadeclipse.platform.swt-65ddc8a5374963e50f794bf6b3b36d84dd19105d.tar.gz
eclipse.platform.swt-65ddc8a5374963e50f794bf6b3b36d84dd19105d.tar.xz
eclipse.platform.swt-65ddc8a5374963e50f794bf6b3b36d84dd19105d.zip
Bug 489640 [GTK3] setting a lot of items to combobox is extremely slow
(Bug fix). Setting wrap causes O(n^2) performance regression because after every insert the drop-down list size is re-computed. Solution: 1) Turn off wrap during insert (to fix bulk insert, e.g setItems(...)) 2) Delay enabling (so that multiple single-insert calls [e.g add(.)] are not delayed if called in a loop. Tests: - Attached snippets: Before fix: Gtk3: 1000ms After fix: Gtk3: 10ms (event faster than gtk2's 23ms). - Child eclipse works well. - All SWT jUnits pass. - Combo box looks same as before. Patchset 4: - Implemented similar logic for removing items to fix performance. Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=4896403 Change-Id: Ibf14b35712277e068bc719d073a482ab5c04fb7f Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT PI')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java19
4 files changed, 33 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index 674d32688d..cd4875fa87 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -5391,6 +5391,18 @@ JNIEXPORT jintLong JNICALL GTK_NATIVE(_1gtk_1combo_1box_1get_1model)
}
#endif
+#ifndef NO__1gtk_1combo_1box_1get_1wrap_1width
+JNIEXPORT jint JNICALL GTK_NATIVE(_1gtk_1combo_1box_1get_1wrap_1width)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jint rc = 0;
+ GTK_NATIVE_ENTER(env, that, _1gtk_1combo_1box_1get_1wrap_1width_FUNC);
+ rc = (jint)gtk_combo_box_get_wrap_width((GtkComboBox *)arg0);
+ GTK_NATIVE_EXIT(env, that, _1gtk_1combo_1box_1get_1wrap_1width_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gtk_1combo_1box_1popdown
JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1combo_1box_1popdown)
(JNIEnv *env, jclass that, jintLong arg0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index 1bd6a98e1f..c4c943401b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -403,6 +403,7 @@ char * GTK_nativeFunctionNames[] = {
"_1gtk_1color_1selection_1set_1has_1palette",
"_1gtk_1combo_1box_1get_1active",
"_1gtk_1combo_1box_1get_1model",
+ "_1gtk_1combo_1box_1get_1wrap_1width",
"_1gtk_1combo_1box_1popdown",
"_1gtk_1combo_1box_1popup",
"_1gtk_1combo_1box_1set_1active",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index c999193244..9bd4eb22c9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -401,6 +401,7 @@ typedef enum {
_1gtk_1color_1selection_1set_1has_1palette_FUNC,
_1gtk_1combo_1box_1get_1active_FUNC,
_1gtk_1combo_1box_1get_1model_FUNC,
+ _1gtk_1combo_1box_1get_1wrap_1width_FUNC,
_1gtk_1combo_1box_1popdown_FUNC,
_1gtk_1combo_1box_1popup_FUNC,
_1gtk_1combo_1box_1set_1active_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
index ef0023c904..855d78da93 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
@@ -1540,6 +1540,7 @@ public class GTK extends OS {
}
/** @method flags=dynamic */
public static final native void _gtk_combo_box_text_insert(long /*int*/ combo_box, int position, byte[] id, byte[] text);
+ /** Do not call directly, instead use Combo.gtk_combo_box_insert(..) */
public static final void gtk_combo_box_text_insert(long /*int*/ combo_box, int position, byte[] id, byte[] text) {
lock.lock();
try {
@@ -1574,6 +1575,7 @@ public class GTK extends OS {
}
/** @method flags=dynamic */
public static final native void _gtk_combo_box_text_remove_all(long /*int*/ combo_box);
+ /** Do not call directly. Call Combo.gtk_combo_box_text_remove_all(..) instead). */
public static final void gtk_combo_box_text_remove_all(long /*int*/ combo_box) {
lock.lock();
try {
@@ -1624,6 +1626,9 @@ public class GTK extends OS {
* @param width cast=(gint)
*/
public static final native void _gtk_combo_box_set_wrap_width(long /*int*/ combo_box, int width);
+ /**
+ * Do not use directly. Instead use Combo.gtk_combo_box_toggle_wrap(..)
+ */
public static final void gtk_combo_box_set_wrap_width(long /*int*/ combo_box, int width) {
lock.lock();
try {
@@ -1632,6 +1637,20 @@ public class GTK extends OS {
lock.unlock();
}
}
+
+ /**
+ * @param combo_box cast=(GtkComboBox *)
+ * @return cast=(gint)
+ */
+ public static final native int _gtk_combo_box_get_wrap_width(long /*int*/ combo_box);
+ public static final int gtk_combo_box_get_wrap_width(long /*int*/ combo_box) {
+ lock.lock();
+ try {
+ return _gtk_combo_box_get_wrap_width(combo_box);
+ } finally {
+ lock.unlock();
+ }
+ }
/**
* @param combo_box cast=(GtkComboBox *)
*/

Back to the top