Skip to content

Should updateProperties iterate properties instead of testing in? #329

Open
@cwillisf

Description

@cwillisf

Currently, the updateProperties function works like this:

updateProperties (properties) {
	let dirty = false;
	if ('position' in properties && (...)) { ... }
	if ('direction' in properties && (...)) { ... }
	if ('scale' in properties && (...)) { ... }
	if ('visible' in properties) { ... }

There's also an if (effectName in properties) check for each effect.

Since updateProperties is called so frequently, it's possible that doing so many in checks is unnecessarily expensive. We could instead iterate the properties of properties (heh) and act on what we find, for example.

It's hard to say for sure whether this would improve performance without benchmarking, though: the properties object tends to not have very many entries per call, but does that mean that the in checks are cheap or does it mean that iterating is an even better idea? Is the time spent handling the in checks even significant to begin with?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions