Skip to content

fix: improve performance of connecting blocks#6876

Merged
BeksOmega merged 11 commits intoRaspberryPiFoundation:developfrom
BeksOmega:fix/wrapping-performance
Mar 16, 2023
Merged

fix: improve performance of connecting blocks#6876
BeksOmega merged 11 commits intoRaspberryPiFoundation:developfrom
BeksOmega:fix/wrapping-performance

Conversation

@BeksOmega
Copy link
Copy Markdown
Contributor

@BeksOmega BeksOmega commented Mar 2, 2023

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide
  • I ran npm run format and npm run lint

The details

Resolves

Related to #6130

Proposed Changes

Optimizes the performance of connecting blocks by:

  • Removing unnessary calls to updateDisabled
  • Only setting the parent once (when connecting) instead of twice (when connecting and disconnecting)

Reason for Changes

Cuts off ~100ms from wrapping an if block around the spaghetti code test blocks.

Test Coverage

Only manual testing :/

Documentation

N/A

Additional Information

Dependent on #6860

@BeksOmega BeksOmega requested a review from a team as a code owner March 2, 2023 21:51
@BeksOmega BeksOmega requested a review from NeilFraser March 2, 2023 21:51
@github-actions github-actions Bot added the PR: fix Fixes a bug label Mar 2, 2023
@BeksOmega BeksOmega marked this pull request as draft March 2, 2023 21:52
@github-actions github-actions Bot added PR: fix Fixes a bug and removed PR: fix Fixes a bug labels Mar 2, 2023
@BeksOmega BeksOmega force-pushed the fix/wrapping-performance branch from 6349740 to 99b95a4 Compare March 8, 2023 15:28
When disconnecting the last block in the stack, the block would not be
rerendered correctly (the top-start corner would not be reshaped)
The order for applying connections was changed so that connections were
applied and then the insertion marker was hidden. This caused an error
because hiding the insertion marker expected there to be a child block
when there was not.
@BeksOmega BeksOmega marked this pull request as ready for review March 8, 2023 16:02
Comment thread core/insertion_marker_manager.ts
@BeksOmega
Copy link
Copy Markdown
Contributor Author

@NeilFraser This is ready for a look! Might be advisable to review this commit-wise.

Comment thread core/block_svg.ts
Comment thread core/insertion_marker_manager.ts
Comment thread core/connection.ts
Comment thread core/connection.ts
if (!parentConnection || !childConnection) {
throw Error('Source connection not connected.');
}
if (otherConnection.targetConnection !== this) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This used to double-check that the connections actually point at each other. Why did you remove that check?

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.

It seems a bit silly when we have the connectReciprocally method. If this check errors, afaict it just means we coded a bug (or someone messed with targetConnection directly, which is also our failing for making that public). Imo, these assertions should be covered by unit tests, not code. But I may be missing some context here.

Comment thread core/connection.ts
Comment thread core/rendered_connection.ts
Comment thread core/insertion_marker_manager.ts
@BeksOmega BeksOmega merged commit c2919c5 into RaspberryPiFoundation:develop Mar 16, 2023
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ConnectionType is now unused, and you missed the lint warning (but now we can all enjoy it! 🤣)

@BeksOmega BeksOmega deleted the fix/wrapping-performance branch May 3, 2023 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: fix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants