From 346675104ae5820f2fb73357803a417d9285113b Mon Sep 17 00:00:00 2001 From: Calum Matheson Date: Fri, 28 Feb 2025 10:06:27 +0000 Subject: [PATCH] Optimizations to InputState::setVoice and NotationNoteInput::setCurrentVoice --- src/engraving/dom/input.cpp | 2 +- src/notation/internal/notationnoteinput.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/engraving/dom/input.cpp b/src/engraving/dom/input.cpp index c2f0ffe0f3d9d..6c208e01bb4c6 100644 --- a/src/engraving/dom/input.cpp +++ b/src/engraving/dom/input.cpp @@ -141,7 +141,7 @@ void InputState::setVoice(voice_idx_t v) { const Score* score = m_segment ? m_segment->score() : nullptr; - if (!score || v >= VOICES || m_track == muse::nidx) { + if (!score || v >= VOICES || v == voice() || m_track == muse::nidx) { return; } diff --git a/src/notation/internal/notationnoteinput.cpp b/src/notation/internal/notationnoteinput.cpp index cfd4369f52fe4..dd2595d27cbdb 100644 --- a/src/notation/internal/notationnoteinput.cpp +++ b/src/notation/internal/notationnoteinput.cpp @@ -658,13 +658,12 @@ void NotationNoteInput::setCurrentVoice(voice_idx_t voiceIndex) { TRACEFUNC; - if (!isVoiceIndexValid(voiceIndex)) { + mu::engraving::InputState& inputState = score()->inputState(); + if (!isVoiceIndexValid(voiceIndex) || voiceIndex == inputState.voice()) { return; } - mu::engraving::InputState& inputState = score()->inputState(); inputState.setVoice(voiceIndex); - notifyAboutStateChanged(); }