[YANGTOOLS-1207] Do not populate namespaces during effective templating Created: 20/Jan/21 Updated: 06/Apr/23 |
|
| Status: | Confirmed |
| Project: | yangtools |
| Component/s: | parser |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Medium |
| Reporter: | Robert Varga | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | pt | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Epic Link: | Parser Performance | ||||||||
| Description |
|
For the purposes of lazy initialization, we are creating StmtContext objects to present a comparison interface. This path is shared with normal inference copy, hence it ends up calling down to StatementSupport.onStatementAdded(). That method serves two purposes:
Namespaces are completely superfluous, as they will end up being thrown away as the template is not retained (not for very long anyway). At this point there cannot be an inference action against the subtree, as it would have already have happened. Skip the callout to onStatementAdded(), or replace it with a different call, so that the effective-template copy is clearly distinguished. This will save us at least two temporary HashMaps – reduce the amount of garbage we produce. |
| Comments |
| Comment by Robert Varga [ 04/Oct/22 ] |
|
Namespaces being completely superfluous is an over-simplification: they are not necessary in case we end up reusing the same instance. The point of this issue is the InferredStatementContext.tryToReusePrototype(): we do not need to trigger onStatementAdded() until we start doing EffectiveCopy.toChildContext() at the last phase of that method. |