Avoid useless reallocation of empty TreeMaps and map iterators 94/4294/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 4 Jun 2020 22:33:16 +0000 (01:33 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 4 Jun 2020 22:33:16 +0000 (01:33 +0300)
commitd3f7c0196ecf58b78574d8b80e1844ecb4e223d6
treeb191768459adb4dfa75d9de1aa55985255d97640
parentb055bfb36cca301ceed0591028d245e152c8c32d
Avoid useless reallocation of empty TreeMaps and map iterators

The problem was that when the database is doing work, MainProgram.run
runs in pretty much busy loop mode and previously it was always
allocating a new TreeMap on each round and also calling Map.entrySet()
to get construct iterators for empty TreeMaps which eventually
accumulates up to somewhat signinificant amount of memory allocated.

Possibly an even more efficient way would be to have the Map be a closed
hashing hashmap instead and then sorting the data for iteration
separately.

gitlab #548

Change-Id: Ib2208dc35b270c9d682362d45f24f1fe01bb8969
bundles/org.simantics.acorn/src/org/simantics/acorn/MainProgram.java