Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[perf] Cache second-update config lookups in hot path#3214

Open
Xekep wants to merge 1 commit intoPryaxis:general-develfrom
TerraZ-Team:pr/micro-perf-secondupdate-settings-cache
Open

[perf] Cache second-update config lookups in hot path#3214
Xekep wants to merge 1 commit intoPryaxis:general-develfrom
TerraZ-Team:pr/micro-perf-secondupdate-settings-cache

Conversation

@Xekep
Copy link

@Xekep Xekep commented Feb 27, 2026

Summary

  • cache Config.Settings once in OnSecondUpdate`n- reuse cached settings for threshold/time checks

Scope

  • focused change in TShock.OnSecondUpdate only
  • no unrelated file changes

@hakusaro
Copy link
Member

@greptile review?

@greptile-apps
Copy link

greptile-apps bot commented Feb 27, 2026

Greptile Summary

Optimizes OnSecondUpdate() by caching Config.Settings at method entry, eliminating redundant property lookups in a hot path that executes every second. The cached reference is consistently used for all configuration checks throughout the method.

  • Reduces property access overhead in per-second update cycle
  • Improves consistency by using a single settings snapshot per update
  • Clean, focused change with no side effects

Confidence Score: 5/5

  • Safe to merge - clean performance optimization with no risks
  • Straightforward caching optimization that reduces property lookups without changing logic or behavior. All configuration references consistently updated to use cached variable. No side effects or edge cases.
  • No files require special attention

Important Files Changed

Filename Overview
TShockAPI/TShock.cs Caches Config.Settings reference at method start to reduce property access overhead in hot path

Last reviewed commit: 03cd331

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants