mirror of
https://github.com/Hopiu/micro.git
synced 2026-03-27 19:30:25 +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
1 changed files with 5 additions and 0 deletions
|
|
@ -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 a new issue