Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of purchasing parts and fix refit bug #1419

Merged

Conversation

sixlettervariables
Copy link
Contributor

While investigating an issue where ammo could not be bought, I noticed a number of huge performance slowdowns in the Purchase Parts screen. I also found a bug w.r.t. refit ID's.

  1. Cache CurrencyManager::getDefaultCurrency. This was extremely expensive and called constantly 25bed25.
  2. Remove text "sanitizing" from PartsInUse 21d2f0f.
  3. Add Campaign::streamSpareParts and use it where allocating a huge ArrayList is unnecessary 51ffcd3.
  4. Add Campaign::findSparePart to take a predicate to quickly find a matching part e8b0652.
  5. Speed up AmmoStorage 43da701, Armor 72ce2f3, BaArmor b1c5751, ProtomekArmor c9fc5c5, and SVArmor a0ab221 bc100ad with findSparePart.
  6. Speed up AmmoBin with findSparePart and streamSpareParts 18a608a. This one could use some eyes
  7. Fix incorrect usage of reference equality of Refit ID's when value equality was intended a90d59b.

The time it takes to purchase 1000 units of AC/20 ammo by clicking 'Buy' is cut by ~70% on my desktop.

These commits are best viewed one by one with whitespace ignored (although I tried to minimize whitespace changes).

@sixlettervariables sixlettervariables changed the title Improve performance of purchasing parts Improve performance of purchasing parts and fix refit bug Jan 22, 2020
- Add new overload for IPartWork::getDetails to
optionally include repair details.
@sixlettervariables sixlettervariables merged commit 517e75e into MegaMek:master Jan 24, 2020
sixlettervariables added a commit to sixlettervariables/mekhq that referenced this pull request Jan 25, 2020
- Ensure all overrides of getDetails include an override of getDetails(boolean)
sixlettervariables added a commit that referenced this pull request Jan 26, 2020
@sixlettervariables sixlettervariables deleted the purchase-part-performance branch October 8, 2020 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants