Opened 3 years ago

Last modified 2 years ago

#5979 new enhancement

Don't initialise null/boolean values in components. — at Version 4

Reported by: Freagarach Owned by:
Priority: Should Have Milestone: Backlog
Component: Simulation Keywords: simple
Cc: Patch: Phab:D3468

Description (last modified by Freagarach)

In many JS components there are a lot of variables created on init that are not strictly necessary.

E.g. in ResourceGatherer: this.lastCarriedType = undefined;.

There are more such examples of which some can have more effect on performance. It would be good to not initialise such values, but create them when needed and delete them when not needed anymore. This saves time on init and serialisation data during a game. (Refs. #3834.)

Also booleans are a good example of variables that need not to be initialised.

Change History (4)

comment:1 by Freagarach, 3 years ago

Patch: Phab:D3468

comment:2 by Freagarach, 3 years ago

In r24993:

Do not initialise null values in cmpGarrisonHolder.

Saves some serialisation data (refs #3834).

Ticket: #5979
Differential revision: ​Phab:D3468
Comments by: @Angen, @Stan

comment:3 by Freagarach, 3 years ago

In 25030:

Give the Garrisonable component the power to set garrisoned on an entity with UnitAI, instead of leaving it to UnitAI.

Since the only way of garrisoning is using cmpGarrisonable.
r9498 / rP9498 introduced the this.isGarrisoned-flag, its meaning was discussed in Phab:D1403.

Refs. #5979, #6081
Differential revision: D2379
Comments by: @elexis, @Stan, @wraitii

comment:4 by Freagarach, 3 years ago

Description: modified (diff)
Summary: Don't initialise null values in components.Don't initialise null/boolean values in components.
Note: See TracTickets for help on using tickets.