Skip to content

Commit

Permalink
Optimizations to InputState::setVoice and NotationNoteInput::setCurre…
Browse files Browse the repository at this point in the history
…ntVoice
  • Loading branch information
mathesoncalum committed Feb 28, 2025
1 parent 52946d6 commit 3466751
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/engraving/dom/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 2 additions & 3 deletions src/notation/internal/notationnoteinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 3466751

Please sign in to comment.