Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 188547 Details for
Bug 333286
[performance] Combo creation is sometimes very slow on gtk
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
333286_fix.txt (text/plain), 2.91 KB, created by
Sergey Prigogin
on 2011-02-08 15:38:51 EST
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Sergey Prigogin
Created:
2011-02-08 15:38:51 EST
Size:
2.91 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.swt >Index: Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java,v >retrieving revision 1.212 >diff -u -r1.212 Combo.java >--- Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java 23 Dec 2010 19:18:09 -0000 1.212 >+++ Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java 8 Feb 2011 20:19:29 -0000 >@@ -11,6 +11,8 @@ > package org.eclipse.swt.widgets; > > >+import java.util.Arrays; >+ > import org.eclipse.swt.*; > import org.eclipse.swt.internal.*; > import org.eclipse.swt.internal.gtk.*; >@@ -571,34 +573,52 @@ > } > > int /*long*/ findPopupHandle (int /*long*/ oldList) { >+ // We get two lists of top-level window handles, one before creation of the combo box >+ // and one after. The first window handle that is present in the second list but not in >+ // the first one is assumed to be the handle of the popup window of the combo box. > int /*long*/ hdl = 0; >- int /*long*/ currentList = OS.gtk_window_list_toplevels(); >- int /*long*/ oldFromList = oldList; >- int /*long*/ newFromList = currentList; >- boolean isFound; >- while (newFromList != 0) { >- int /*long*/ newToplevel = OS.g_list_data(newFromList); >- isFound = false; >- oldFromList = oldList; >- while (oldFromList != 0) { >- int /*long*/ oldToplevel = OS.g_list_data(oldFromList); >- if (newToplevel == oldToplevel) { >- isFound = true; >- break; >- } >- oldFromList = OS.g_list_next(oldFromList); >+ int /*long*/ newList = OS.gtk_window_list_toplevels(); >+ int[] oldHandles = getSortedListData(oldList, 1000); >+ int[] newHandles = getSortedListData(newList, oldHandles.length); >+ for (int i = 0, j = 0; i < newHandles.length; i++, j++) { >+ hdl = newHandles[i]; >+ if (hdl == 0) { >+ break; > } >- if (!isFound) { >- hdl = newToplevel; >+ int oldHandle = j < oldHandles.length ? oldHandles[j] : 0; >+ if (oldHandle != 0 && oldHandle < hdl) { >+ i--; >+ } else if (hdl != oldHandle) { > break; > } >- newFromList = OS.g_list_next(newFromList); > } > OS.g_list_free(oldList); >- OS.g_list_free(currentList); >+ OS.g_list_free(newList); > return hdl; > } > >+/** >+ * Retrieves data from a list of window handles and returns it in a sorted array. >+ * The returned array may be padded with zeros. >+ * >+ * @param listHandle a list handle >+ * @param initialSize initial length of the array. >+ * @return window handles in ascending order. >+ */ >+private int[] getSortedListData(int listHandle, int initialSize) { >+ int[] data = new int[initialSize]; >+ int count = 0; >+ for (int item = listHandle; item != 0; item = OS.g_list_next(item)) { >+ if (count >= data.length) { >+ int[] oldData = data; >+ data = new int[data.length * 2]; >+ System.arraycopy(oldData, 0, data, 0, oldData.length); >+ } >+ data[count++] = OS.g_list_data(item); >+ } >+ Arrays.sort(data, 0, count); >+ return data; >+} > > void findButtonHandle() { > /*
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 333286
: 188547 |
188711
|
188725
|
189628