Commit 9f7a7a8
chore: Improve performance of
continues: #3585
This PR adds an equality check to the `NetworkList<T>` indexer setter,
aligning its behavior with `NetworkVariable<T>.Value`. Since
`NetworkList<T>` already constrains `T` to `IEquatable<T>`, this change
is both safe and broadly applicable. It avoids redundant assignments
when the new value is equal to the current value, which improves runtime
efficiency and avoids unnecessary event dispatch and network
synchronization.
## Changelog
- Changed: Optimized `NetworkList<T>` indexer setter to skip operations
when the new value equals the existing value, improving performance by
avoiding unnecessary list events and network synchronization.
## Testing & QA
This is a very small optimization in an area of code that is deeply
covered by unit and integration tests. No manual testing is required.
## Documentation
As there are no API or behaviour changes, no documentation is required
## Backport
This is a new optimization and so doesn't need to be backported
---------
Co-authored-by: Yuto Harada <[email protected]>NetworkList set operation (#3587)1 parent 5dc5435 commit 9f7a7a8
File tree
2 files changed
+9
-0
lines changed- com.unity.netcode.gameobjects
- Runtime/NetworkVariable/Collections
2 files changed
+9
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
617 | 617 | | |
618 | 618 | | |
619 | 619 | | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
620 | 627 | | |
621 | 628 | | |
622 | 629 | | |
| |||
0 commit comments