maptool icon indicating copy to clipboard operation
maptool copied to clipboard

fix `setTableEntry()` performance

Open Azhrei opened this issue 2 months ago • 1 comments

Identify the Bug or Feature request

Closes #4769

Description of the Change

The original code for setTableEntry() was executing an O(n) algorithm to add a single element to the table, causing massive slowdown on larger tables as well as excessive memory churn (OP claimed 32-48GB was required to add 3200 elements to a table).

To correct this, the original LookupTable implementation was modified to add a setTableEntry() method that will overwrite an existing entry. The original implementation used addTableEntry() to copy the existing table to a new one as overwriting a single entry was not possible.

Also included are refactoring of redundant code blocks into a private method, checkTableAccess(), as well as refactoring to move large code blocks for each subfunction into their own private methods.

Possible Drawbacks

There shouldn't be any.

Documentation Notes

None.

Release Notes

  • fixed performance issue with setTableEntry() when used with large tables

This change is Reviewable

Azhrei avatar Apr 30 '24 23:04 Azhrei