1
0
mirror of https://github.com/zyedidia/micro synced 2024-07-01 06:54:31 +00:00

autosave: don't save unmodified buffer (#3356)

Saving a buffer every time without even checking if it was modified
(i.e. even when the user is not editing the buffer) is wasteful,
especially if the autosave period is set to a short value.
This commit is contained in:
Dmytro Maluka 2024-06-17 12:59:32 +02:00 committed by GitHub
parent ced6d9487a
commit dc62dd9d82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -95,6 +95,11 @@ func (b *Buffer) Save() error {
// AutoSave saves the buffer to its default path
func (b *Buffer) AutoSave() error {
// Doing full b.Modified() check every time would be costly, due to the hash
// calculation. So use just isModified even if fastdirty is not set.
if !b.isModified {
return nil
}
return b.saveToFile(b.Path, false, true)
}