Skip to content

refactor: add move constructor and move assignment operator to ValueDesc - #3150

Merged
ice0 merged 1 commit into
synfig:masterfrom
rodolforg:badly-used-valuedesc-move
Oct 23, 2024
Merged

ice0 merged 1 commit into
synfig:masterfrom
rodolforg:badly-used-valuedesc-move

Conversation

@rodolforg

Copy link
Copy Markdown
Contributor

Note: sadly the usage is low.
By adding debug messages on copy constructor and assignment operator, it can be seen there is a lot of copy while clicking around, moving mouse or even after a Alt+Tab to change to other application.

Note: sadly the usage is low.
By adding debug messages on copy constructor and assignment operator,
it can be seen there is *a lot* of copy while clicking around, moving
mouse or even after a Alt+Tab to change to other application.
}

// move
ValueDesc(ValueDesc&& other) noexcept

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: lets avoid unnecessary default constructions followed by assignments

ValueDesc(ValueDesc&& other) noexcept
    : layer(std::move(other.layer)),
      name(std::move(other.name)),
      parent_value_node(std::move(other.parent_value_node)),
      index(other.index),
      waypoint_time(std::move(other.waypoint_time)),
      canvas(std::move(other.canvas)),
      id_changed_connection(std::move(other.id_changed_connection)),
      sub_names(std::move(other.sub_names)),
      parent_desc(std::move(other.parent_desc)),
      links_count(other.links_count)
{
    other.parent_desc = nullptr;
    other.links_count = 0;
}

@rodolforg rodolforg Aug 6, 2023 •

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 was just placing everything in a single method to avoid mistakes. For example, someone adds a new "field"/property to ValueDesc and forget to add to both move-related methods.

And these methods declarations are only needed due to this explicit pointer parent_desc :/

@ice0

ice0 commented Aug 3, 2023

Copy link
Copy Markdown
Collaborator

By adding debug messages on copy constructor and assignment operator, it can be seen there is a lot of copy while clicking around, moving mouse or even after a Alt+Tab to change to other application.

This is interesting. I'll try to check that too.

@ice0

ice0 commented Aug 6, 2023

Copy link
Copy Markdown
Collaborator

By adding debug messages on copy constructor and assignment operator, it can be seen there is a lot of copy while clicking around, moving mouse or even after a Alt+Tab to change to other application.

It looks like basically all the calls come from CanvasView::rebuild_ducks().

@ice0
ice0 merged commit 4fadf28 into synfig:master Oct 23, 2024
@ice0

ice0 commented Oct 23, 2024

Copy link
Copy Markdown
Collaborator

Merged. Thank you!

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.

3 participants