The reason I do the check that way is because if the user adds a character, and then deletes it, the buffer has not been modified, but if you just set a bool to true when an insert event happens, it will think the buffer has been modified.
If there is a better way to do this please let me know.
In general, you should optimize for common use cases. In a file editor, you will be modifying the file and when you go to save it, it will be different.
If there is a better way to do this please let me know.