Repository: GraphiteEditor/Graphite
File: editor/src/messages/tool/tool_messages/path_tool.rs (Rust)

Code before:
		tool_options: &Self::ToolOptions,
		responses: &mut VecDeque<Message>,
	) -> Self {
		let ToolActionMessageContext {
			document,
			input,
			viewport,
			shape_editor,
			..
		} = tool_action_data;

		update_dynamic_hints(self, responses, shape_editor, document, tool_data, tool_options, input.mouse.position);

		let ToolMessage::Path(event) = event else { return self };

		// TODO(mTvare6): Remove once gizmos are implemented for path_tool
		tool_data.pivot_gizmo.state.disabled = true;

		match (self, event) {
			(_, PathToolMessage::SelectionChanged) => {
				// Set the newly targeted layers to visible
				let target_layers = document.network_interface.selected_nodes().selected_layers(document.metadata()).collect();

				shape_editor.set_selected_layers(target_layers);

				responses.add(MenuBarMessage::SendLayout);
				responses.add(OverlaysMessage::Draw);
				self
			}
			(_, PathToolMessage::UpdateSelectedPointsStatus { overlay_context }) => {
				let display_anchors = overlay_context.visibility_settings.anchors();
				let display_handles = overlay_context.visibility_settings.handles();

				shape_editor.update_selected_anchors_status(display_anchors);
				shape_editor.update_selected_handles_status(display_handles);

				let new_points = shape_editor.selected_points().copied().collect::<Vec<_>>();
				tool_data.sync_history(&new_points);

				self
			}
			(_, PathToolMessage::TogglePointEditing) => {
				// Clicked on the point edit mode button
				let point_edit = tool_options.path_editing_mode.point_editing_mode;
				let segment_edit = tool_options.path_editing_mode.segment_editing_mode;
				let multiple_toggle = tool_data.multiple_toggle_pressed;

				if point_edit && !segment_edit {
					return self;
				}


Review comment (performance):
In both of these calls, `MenuBarMessage::SendLayout` is expensive. Can you find a way to check if a re-send is necessary before making the call, so it's conditional instead of always?

Code after:
		tool_options: &Self::ToolOptions,
		responses: &mut VecDeque<Message>,
	) -> Self {
		let ToolActionMessageContext {
			document,
			input,
			viewport,
			shape_editor,
			..
		} = tool_action_data;

		update_dynamic_hints(self, responses, shape_editor, document, tool_data, tool_options, input.mouse.position);

		let ToolMessage::Path(event) = event else { return self };

		// TODO(mTvare6): Remove once gizmos are implemented for path_tool
		tool_data.pivot_gizmo.state.disabled = true;

		match (self, event) {
			(_, PathToolMessage::SelectionChanged) => {
				// Set the newly targeted layers to visible
				let target_layers = document.network_interface.selected_nodes().selected_layers(document.metadata()).collect();

				shape_editor.set_selected_layers(target_layers);

				let new_state = make_path_editable_is_allowed(&mut document.network_interface).is_some();
				if tool_data.make_path_editable_is_allowed != new_state {
					responses.add(MenuBarMessage::SendLayout);
				}
				responses.add(OverlaysMessage::Draw);
				self
			}
			(_, PathToolMessage::UpdateSelectedPointsStatus { overlay_context }) => {
				let display_anchors = overlay_context.visibility_settings.anchors();
				let display_handles = overlay_context.visibility_settings.handles();

				shape_editor.update_selected_anchors_status(display_anchors);
				shape_editor.update_selected_handles_status(display_handles);

				let new_points = shape_editor.selected_points().copied().collect::<Vec<_>>();
				tool_data.sync_history(&new_points);

				self
			}
			(_, PathToolMessage::TogglePointEditing) => {
				// Clicked on the point edit mode button
				let point_edit = tool_options.path_editing_mode.point_editing_mode;
				let segment_edit = tool_options.path_editing_mode.segment_editing_mode;
				let multiple_toggle = tool_data.multiple_toggle_pressed;

				if point_edit && !segment_edit {