It’s all in my first reply to cpr:s post from 2018
Either Jules didn’t really understand my point of not inserting note-offs in updateMatchedPairs() or he didn’t care. To his defence (if he ever would need one ) one might put forth that the initial post was about a slightly different problem of updateMatchedPairs() and from rereading the topic now, I see it took a direction towards efficiency instead of fixing the main issue (improper changing of the the midi score by inserting unneccessary note-offs).
This subject have also been touched upon before like here
How to trigger? Just take a midi file with overlapping note-ons with same note number and channel