Skip to content

Finish processor link changes optimization#12232

Open
cardillan wants to merge 1 commit into
Anuken:masterfrom
cardillan:processor-links
Open

Finish processor link changes optimization#12232
cardillan wants to merge 1 commit into
Anuken:masterfrom
cardillan:processor-links

Conversation

@cardillan

Copy link
Copy Markdown
Contributor

Commit d13afc1 contains changes to optimize processor link changes, but the job wasn't finished. The new code only runs when a linked block is deleted. When links to existing blocks are added/removed via GUI, the code is still recompiled from scratch.

I've updated the code which manages adding/removing links to use the new system. For this to work, the variables representing linked blocks must exist in the executor (so that they're available via optionalVar()), so I'm copying them from the assembler to the executor as well - built-ins and literals are still excluded to keep the array small.

As a side effect, it is now possible to read linked blocks which also exist as a variable in the code via the read instruction. This is a bit inconsistent, as blocks that are linked but not referenced from the code can't be read that way. There's the #11838 PR for that; if you accept this PR, I'll update that one to be compatible.

If your pull request is not translation or serverlist-related, read the list of requirements below and check each box:

  • I have read the contribution guidelines.
  • I have ensured that my code compiles, if applicable.
  • I have ensured that any new features in this PR function correctly in-game, if applicable.

stop = false;
nameMap = null;
vars = builder.vars.values().toSeq().retainAll(var -> !var.constant).toArray(LVar.class);
vars = builder.vars.values().toSeq().retainAll(var -> !var.constant || var.name.charAt(0) != '_' && var.name.charAt(0) != '@').toArray(LVar.class);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to add only the constants representing the linked variables here, to keep the array small. Before, all constants were excluded. Now I'm excluding the constants representing mlog literals (triple underscore) and builtin variables (@this, @links, etc.). What remains should be the constants representing linked blocks.

I could include the builtins as well, and they would be remotely readable, but the only really useful one is @links, and since links can't be read remotely anyway, its utility is limited. I'd probably add them in #11838.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants