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

fix: overload when setting item decay when player logs in #2927

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dudantas
Copy link
Contributor

Description

This change optimizes the decay initiation process for items within containers. Previously, Container::startDecaying() method would recursively start the decay for each item in a container upon the container's own decay initiation. This could lead to inefficiencies, especially with a large number of nested containers. The updated approach collects all decaying items in a vector first and then initiates decay after all have been added, improving performance by reducing overhead and simplifying the management of decay states.

Behaviour

Actual

Previously, initiating decay inside a container would immediately start the decay process for each item inside the container and all nested containers, leading to deep recursive calls and potential performance issues in cases with many nested containers.

image

Expected

With the new implementation, the decay process is deferred and managed collectively after all items are loaded and their relationships established. This ensures that all necessary decays are handled efficiently in a single, managed operation, reducing the recursive depth and improving the performance.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Code improvement

How Has This Been Tested

  • Performance tests were conducted to compare the CPU and memory usage before and after the change, showing a noticeable improvement in scenarios with large numbers of nested containers.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I checked the PR checks reports
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Copy link
Contributor

@phacUFPE phacUFPE left a comment

Choose a reason for hiding this comment

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

Approved! Nice catch! You could also check for stopDecay.

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