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:
parent
ced6d9487a
commit
dc62dd9d82
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user