On Fri, 20 Mar 2026 19:56:14 GMT, Philemon Hilscher <[email protected]> wrote:
> The problem was caused, because the items were added individually instead of > batched. Here is a performance comparison created with a profiler. > > | Before | After | > | --- | --- | > | <img width="912" height="489" alt="image" > src="https://github.com/user-attachments/assets/794314ef-09d6-49e1-bbbe-d2f1a5c97cf2" > />|<img width="922" height="497" alt="Screenshot 2026-03-20 202806" > src="https://github.com/user-attachments/assets/e3a38fde-97dc-4889-a229-3539787c60e9" > />| > > The tests added here back up the functionality of the choice box itself since > this is just a performance improvement. modules/javafx.controls/src/main/java/javafx/scene/control/skin/ChoiceBoxSkin.java line 372: > 370: } > 371: > 372: private void addPopupItem(int i, final Collection<? extends T> col) { Should be renamed to `addPopupItems`, as it is now always a bulk operation. While here, we could rename `i` to `index`, to make that clear. modules/javafx.controls/src/test/java/test/javafx/scene/control/ChoiceBoxTest.java line 616: > 614: ContextMenu choiceBoxPopup = > ChoiceBoxSkinNodesShim.getChoiceBoxPopup((ChoiceBoxSkin<?>) box.getSkin()); > 615: > 616: for (int i = 0; i < 10; i++) { Checking the `ChoiceBox` code, we probably should also have a test that adds multiple items at a given index. Something like `box.getItems().addAll(5, items);`. To test the following code: https://github.com/openjdk/jfx/blob/6315e1f75d3939b26d08cbcfbc496ced386def8f/modules/javafx.controls/src/main/java/javafx/scene/control/skin/ChoiceBoxSkin.java#L108-L111 ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/2118#discussion_r2971364865 PR Review Comment: https://git.openjdk.org/jfx/pull/2118#discussion_r2971363363
