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

Optimize loading items, improve startup time #6562

Merged
merged 4 commits into from
Sep 5, 2023

Conversation

Lancej
Copy link
Contributor

@Lancej Lancej commented Aug 30, 2023

These changes improve PoB startup time by about 970 ms.

main:Init() average time
Before: 2709 ms
After: 1738 ms

Changes:

  • In ParseRaw first loop that creates self.rawLines now done with one gmatch call.
  • processInfluenceLine function replaced with lookup table.
  • "specName, specVal" parsing done with less string match calls.
  • Line flags like "{crafted}" or " (implicit)" are all parsed with just 2 gsub calls instead of the many match calls like before. These 2 gsub calls also replace the many gsub calls to remove the flags from the line.
  • NormaliseQuality was called at the end of ParseRaw then again in Main:Init. Instead the call from Main is moved into ParseRaw as well. I'm not sure if NormaliseQuality should have different results if you call it twice in a row but I already changed a lot and decided to leave it alone for now and just call it twice still. Moving it saved the need for calling BuildAndParseRaw for uniques.
  • getLineRangeMinMax removed and replaced with a find call.
  • In sanitiseItemText removed newline and space trimming gsub calls because ParseRaw line splitting already does both. Also does a find for chars 128-255 or '<' before doing the rest of the gsub calls.
  • In BuildModListForSlotNum set BasePercentile variables to 1 when creating an item with no defense attributes in the raw text. This one is a bug fix and not a speed up. I added a test for this in the new file TestItemParse_spec.lua, it's the last test in that file and it failed before but passes now.
  • Other smaller changes.

Steps taken to verify a working solution:

Added TestItemParse_spec.lua with a bunch of item parsing tests. Also tried loading several builds to make sure items were the same and checked items from the uniques/rares item DB.

@LocalIdentity LocalIdentity added the enhancement New feature, calculation, or mod label Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, calculation, or mod
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants