Commit c1f86c6
authored
chore: Optimize NetworkVariable property accessors (#3689)
## Purpose of this PR
Optimize property accessors around `NetworkVariable`
1. Keep a self reference to `m_NetworkBehaviour`, `m_NetworkObject` and
`m_NetworkManager`
2. Swap `CanWrite` and `CannotWrite` to aggressively inlined functions
3. Store a `m_UseServerTime` boolean that can be calculated once rather
than on every check on the NetworkVar
4. Add early returns in the `NetowrkVariableDeltaMessage` to reduce
indentation and increase readability.
### Jira ticket
Needs a JIRA ticket
### Changelog
- Changed: Improved performance of NetworkVariable property accessors.
## Documentation
- No documentation changes or additions were necessary.
## Testing & QA (How your changes can be verified during release
Playtest)
These changes are less risky and should be covered by the automated
testing.
### Functional Testing
[//]: # (If checked, List manual tests that have been performed.)
_Manual testing :_
- [ ] `Manual testing done`
_Automated tests:_
- [x] `Covered by existing automated tests`
- [ ] `Covered by new automated tests`
_Does the change require QA team to:_
- [ ] `Review automated tests`?
- [ ] `Execute manual tests`?
- [ ] `Provide feedback about the PR`?
If any boxes above are checked the QA team will be automatically added
as a PR reviewer.
## Backports
This is a performance improvement so backporting this fix isn't
necessary.1 parent b78d4eb commit c1f86c6
File tree
6 files changed
+218
-210
lines changed- com.unity.netcode.gameobjects
- Runtime
- Messaging/Messages
- NetworkVariable
- Collections
6 files changed
+218
-210
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
Lines changed: 167 additions & 170 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
| 220 | + | |
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
432 | | - | |
| 432 | + | |
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | | - | |
| 459 | + | |
460 | 460 | | |
461 | 461 | | |
462 | 462 | | |
| |||
494 | 494 | | |
495 | 495 | | |
496 | 496 | | |
497 | | - | |
| 497 | + | |
498 | 498 | | |
499 | 499 | | |
500 | 500 | | |
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
546 | | - | |
| 546 | + | |
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
| |||
579 | 579 | | |
580 | 580 | | |
581 | 581 | | |
582 | | - | |
| 582 | + | |
583 | 583 | | |
584 | 584 | | |
585 | 585 | | |
| |||
613 | 613 | | |
614 | 614 | | |
615 | 615 | | |
616 | | - | |
| 616 | + | |
617 | 617 | | |
618 | 618 | | |
619 | 619 | | |
| |||
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
269 | | - | |
| 269 | + | |
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
| |||
328 | 328 | | |
329 | 329 | | |
330 | 330 | | |
331 | | - | |
| 331 | + | |
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
| 373 | + | |
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
| |||
Lines changed: 37 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
| |||
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
63 | | - | |
64 | | - | |
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
| |||
108 | 111 | | |
109 | 112 | | |
110 | 113 | | |
111 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
112 | 117 | | |
113 | 118 | | |
114 | 119 | | |
115 | 120 | | |
116 | 121 | | |
117 | 122 | | |
118 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
119 | 126 | | |
120 | 127 | | |
121 | | - | |
| 128 | + | |
122 | 129 | | |
123 | 130 | | |
124 | 131 | | |
125 | 132 | | |
126 | 133 | | |
127 | | - | |
| 134 | + | |
128 | 135 | | |
129 | 136 | | |
130 | 137 | | |
131 | 138 | | |
132 | 139 | | |
133 | 140 | | |
134 | 141 | | |
135 | | - | |
| 142 | + | |
136 | 143 | | |
137 | 144 | | |
138 | 145 | | |
| |||
251 | 258 | | |
252 | 259 | | |
253 | 260 | | |
254 | | - | |
| 261 | + | |
255 | 262 | | |
256 | 263 | | |
257 | 264 | | |
| |||
267 | 274 | | |
268 | 275 | | |
269 | 276 | | |
270 | | - | |
| 277 | + | |
271 | 278 | | |
272 | 279 | | |
273 | 280 | | |
| |||
286 | 293 | | |
287 | 294 | | |
288 | 295 | | |
289 | | - | |
| 296 | + | |
290 | 297 | | |
291 | | - | |
| 298 | + | |
292 | 299 | | |
293 | 300 | | |
294 | 301 | | |
295 | 302 | | |
296 | 303 | | |
297 | 304 | | |
298 | 305 | | |
299 | | - | |
| 306 | + | |
300 | 307 | | |
301 | | - | |
| 308 | + | |
302 | 309 | | |
303 | 310 | | |
304 | 311 | | |
305 | 312 | | |
306 | 313 | | |
307 | 314 | | |
308 | 315 | | |
309 | | - | |
| 316 | + | |
310 | 317 | | |
311 | 318 | | |
312 | 319 | | |
| |||
345 | 352 | | |
346 | 353 | | |
347 | 354 | | |
348 | | - | |
| 355 | + | |
349 | 356 | | |
350 | 357 | | |
351 | 358 | | |
| |||
355 | 362 | | |
356 | 363 | | |
357 | 364 | | |
358 | | - | |
| 365 | + | |
359 | 366 | | |
360 | 367 | | |
361 | 368 | | |
| |||
377 | 384 | | |
378 | 385 | | |
379 | 386 | | |
380 | | - | |
| 387 | + | |
381 | 388 | | |
382 | 389 | | |
383 | 390 | | |
384 | 391 | | |
385 | 392 | | |
386 | 393 | | |
387 | | - | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
388 | 399 | | |
389 | 400 | | |
390 | 401 | | |
391 | 402 | | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
| 403 | + | |
| 404 | + | |
398 | 405 | | |
399 | | - | |
| 406 | + | |
400 | 407 | | |
401 | 408 | | |
402 | 409 | | |
| |||
467 | 474 | | |
468 | 475 | | |
469 | 476 | | |
470 | | - | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
471 | 481 | | |
472 | 482 | | |
473 | 483 | | |
0 commit comments