Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8123472

isSelected in TableViewSelectionModel is called too many times

    XMLWordPrintable

Details

    Description

      When you select a cell in a TableView, the ObservableList containing the selectedCells is updated.

      Then, EACH TableCell in the TableView has its "selectedListener" reacting.
      It's then calling "updateSelection();", and then calling "isSelected()".

      And in that last method, you just go through the entire list of selectedCells to see whether that cell is selected or not.

      I think it's pretty heavy. For example, if I maintain shift and select 500 cells, I'm can count that we're calling isSelected 20 000 times. And keep in mind that each call to that method induce going through the whole list of selectedCells which is itself becoming bigger each time we're adding a cell.

      Do you have opinion on this? I would recommend to directly hit the selectedCell when selection in happening instead of having a listener on each cell. Because right now selection is very slow..

      Another solution could be like the "selectAll" method. You could detect that a big selection with SHIFT is happening, And then just prepare all the cell to add, and just add them in one time in the list instead of calling "select()" for each one of them.

      Attachments

        1. rt33442_2.patch
          24 kB
        2. rt33442_3.patch
          41 kB
        3. rt33442.patch
          15 kB
        4. RT33619_SlowTableShiftSelect.java
          2 kB

        Activity

          People

            jgiles Jonathan Giles
            shadzic Samir Hadzic
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: