4 ms·
The implementation of checking if a buffer is dirty seems a bit... odd. It compares the saved text with the buffer text. Seems like a bool should do fine based
by cheez 11y ago
The implementation of checking if a buffer is dirty seems a bit... odd. It compares the saved text with the buffer text. Seems like a bool should do fine based on other operations I saw in that file.
https://github.com/zyedidia/micro/blob/master/src/buffer.go#L86 https://github.com/zyedidia/micro/blob/master/src/buffer.go#...
- zyedidia 11y agoThe 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.
- copperx 11y agoWhat about setting the dirty bit with a boolean while you're working, but then before saving, do the diff to check if the file really needs saving?
- cheez 11y agoIn 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. What do you gain by doing it this way?