#4333 closed enhancement (fixed)
[Patch] Speed up the Guard component
Reported by: | wraitii | Owned by: | mimo |
---|---|---|---|
Priority: | Must Have | Milestone: | Alpha 22 |
Component: | UI & Simulation | Keywords: | patch |
Cc: | Patch: |
Description
The guard component is quite slow for no good reason. It uses OnGlobalOwnershipChanged, and since so many entities have a guard component, it becomes really slow when any ownership changed message gets sent.
I have changed it very slightly to not do that. Makes it go from a weird performance bottleneck to basically irrelevant, as it should be.
Putting as must have because it's actually a huge optimisation for the change.
Branch is here: https://github.com/wraitii/0ad/commits/guardRewrite . All changes in the one commit.
Attachments (1)
Change History (7)
comment:1 by , 7 years ago
comment:3 by , 7 years ago
When reviewing this patch, i noticed 2 problems in the original code:
- diplomacyChanges were not taken into account
- line 87 of Guard.js looks wrong to me
And in your patch, the taking account of renamed entities is only partial.
I've attached a new patch which should fix all of that.
by , 7 years ago
Attachment: | guard-4333.patch added |
---|
comment:4 by , 7 years ago
Looks good. For the promotion/transform.js change, I'd commit those as part of #4334 Feel free to commit it.
comment:6 by , 7 years ago
Keywords: | review removed |
---|---|
Milestone: | Work In Progress → Alpha 22 |
Line 65 of guard.js since you actually nuke the var keyword you should also nuke the for each.
Jslinting the file might be nice I think.