-
-
Notifications
You must be signed in to change notification settings - Fork 601
Description
Optimize is generally used for optimizing steps (e.g. eliminating them by having ancestors do their work for them, or similar); however it's sometimes also used for sending information up the tree where there is no other appropriate time to do it (i.e. data that can't be sent until the full tree is established - like "do I need to load cursors or not" isn't known until we see whether anyone accessed the cursor fields or not).
Here's an example:
crystal/grafast/grafast/src/steps/load.ts
Lines 189 to 193 in b72034f
// Tell our parent we only need certain attributes | |
$source.addAttributes(this.attributes); | |
for (const [key, value] of Object.entries(this.params)) { | |
$source.setParam(key, value); | |
} |
Saying about the attributes is an optimization (without it, all attributes would be loaded); but saying about the params is required - without it we might not be applying the right filters/etc.
We should add a new lifecycle method that does these essential tree-walking steps before optimize is called. Maybe at the end of plan before or just slightly after tree shaking? (Note: refs should be retained for this.)