Skip to content

Fix pest farming performance + improve rate impact display#688

Open
lixckxx wants to merge 3 commits into
EliteFarmers:mainfrom
lixckxx:pestfarming-performance-fixes
Open

Fix pest farming performance + improve rate impact display#688
lixckxx wants to merge 3 commits into
EliteFarmers:mainfrom
lixckxx:pestfarming-performance-fixes

Conversation

@lixckxx

@lixckxx lixckxx commented Jun 23, 2026

Copy link
Copy Markdown

Fix pest farming performance + improve rate impact display

Changes:

  • Replaced repeated toLocaleString calls with a cached Intl.NumberFormat map in +page.svelte and pest-rate-breakdown.svelte to avoid recreating formatters on every call
  • Moved inline .filter().sort() pet chain into a derived sortedPets = $derived.by() field in PestFarmingPageContext, so sorting and filtering run reactively instead of on every render
  • Added #lastRateStateKey, #lastGearRateStateKey, and #lastPetRateStateKey fields to handle state-based cache invalidation, replacing the previous size-threshold cache clears (>500 / >1000 entries)
  • Hoisted state-key checks to the top of getPhasePieceRateImpact, getSharedEquipmentPieceRateImpact, and getPetRateImpact, before cache lookup, so stale entries are invalidated immediately after state changes
  • Moved memo clearing in #calculatePestRateImpact to occur before cache lookup, keyed on result.stateKey, ensuring the cache is reset before new entries are stored
  • Refactored getPestRateImpact and rateImpactItems to reuse the existing pestRateCalculator and pestRateResult derived values instead of instantiating a new calculator and recomputing on every call
  • Introduced #itemPriceCache in PestFarmingPageContext so pestRatePriceBook only fetches sell values for new item IDs, skipping previously resolved items
  • Replaced Math.min(...auctionPrices) with a reduce() to avoid spreading large arrays into function calls, and simplified bazaar/auction selection logic into a direct comparison
  • Replaced triple spread-into-Set pattern in neededItems with sequential Set.add() calls to reduce intermediate allocations during recomputation

Comment thread .env.example

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intend to delete the .env.example file?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, thats my bad, thought i didnt include that change when i pushed

@lixckxx lixckxx force-pushed the pestfarming-performance-fixes branch from 4db25b8 to cdb6997 Compare June 24, 2026 14:09
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.

2 participants