-
Notifications
You must be signed in to change notification settings - Fork 0
perf: update framework submodule + optimize gameplay hot paths #216
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
Changes from all commits
74cdcb4
c2c3927
6537aec
da41f94
28bd032
4a02dde
94c68da
b977884
51f7b00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,19 +36,29 @@ protected override void Update() | |
| double latestValidTime = clock.CurrentTime; | ||
| double earliestTimeValid = latestValidTime - 1000 * gameplayClock.GetTrueGameplayRate(); | ||
|
|
||
| // Timestamps are added in chronological order (from clock.CurrentTime), | ||
| // so we can use binary-search-style trimming instead of per-element RemoveAt. | ||
|
|
||
| // Trim future timestamps caused by rewinding (remove from the end in one batch). | ||
| // RemoveRange from the end is a single operation vs repeated RemoveAt calls. | ||
| int trimStart = timestamps.Count; | ||
|
|
||
| while (trimStart > 0 && timestamps[trimStart - 1] > latestValidTime) | ||
| trimStart--; | ||
|
|
||
| if (trimStart < timestamps.Count) | ||
| timestamps.RemoveRange(trimStart, timestamps.Count - trimStart); | ||
|
|
||
|
Comment on lines
+39
to
+51
|
||
| // Count timestamps within the valid 1-second window. | ||
| // Since the list is in chronological order, scan backwards until we leave the window. | ||
| int count = 0; | ||
|
|
||
| for (int i = timestamps.Count - 1; i >= 0; i--) | ||
| { | ||
| // handle rewinding by removing future timestamps as we go | ||
| if (timestamps[i] > latestValidTime) | ||
| { | ||
| timestamps.RemoveAt(i); | ||
| continue; | ||
| } | ||
|
|
||
| if (timestamps[i] >= earliestTimeValid) | ||
| count++; | ||
| if (timestamps[i] < earliestTimeValid) | ||
| break; | ||
|
|
||
| count++; | ||
| } | ||
|
|
||
| Value = count; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These bindables are initialised in
load()viaGetBoundCopy(), butDispose()can run even ifload()never executed (note the existingIsNotNull()guards for clients). CallingUnbindAll()unconditionally here can therefore throw if any of these fields are still null at disposal time. Consider initialising them at declaration (e.g.new Bindable<...>()+BindTo(...)inload()), or making them nullable and using null-conditional unbinds.