Skip to content

Conversation

@BenjaminDeleze
Copy link

Replace instanceof by a check with nodeType when possible because it:

  • improves the performance
    | Node | Instanceof | nodeType |
    | --- | --- | --- |
    |Background| 0.06ms | 0.019 ms |
    |Shape| 0.27ms | 0.077ms |
    |Robot| 0.28ms | 0.09ms |
  • moreover using instanceof was the cause of a lot of imports and we had circular dependencies errors by the past.

The only reason to still use instanceofsometimes it to check for a node and its derived ones. For example, when checking
if (node instanceof WbGroup)it checks against group, but also, pose, transform, solid, and so on.

This PR also adds support for castShadows and isPickable in WbShape that were missing.

@BenjaminDeleze BenjaminDeleze added enhancement Implementation of a minor feature cleanup Any design, code, file or folder cleanup optimization Make the code faster to execute labels Jul 6, 2023
@BenjaminDeleze BenjaminDeleze added this to the R2023b-rev1 milestone Jul 6, 2023
@BenjaminDeleze BenjaminDeleze self-assigned this Jul 6, 2023
@BenjaminDeleze BenjaminDeleze marked this pull request as ready for review July 7, 2023 06:43
@BenjaminDeleze BenjaminDeleze requested a review from a team as a code owner July 7, 2023 06:43
@BenjaminDeleze BenjaminDeleze requested a review from omichel July 7, 2023 06:43
Copy link
Member

@omichel omichel left a comment

Choose a reason for hiding this comment

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

Nice clean-up.

@BenjaminDeleze BenjaminDeleze merged commit 5c420a2 into master Jul 7, 2023
@BenjaminDeleze BenjaminDeleze deleted the cleanup-instanceof branch July 7, 2023 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Any design, code, file or folder cleanup enhancement Implementation of a minor feature optimization Make the code faster to execute

Development

Successfully merging this pull request may close these issues.

3 participants