Skip to content

Commit

Permalink
Move defer up
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Jun 27, 2024
1 parent 03f9910 commit 5f3167a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/persistedmap/persistedmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,12 @@ func (p *PersistedMap) flushRoutine() {

func (p *PersistedMap) flush() error {
p.mu.Lock()
defer p.mu.Unlock()

if !p.shouldSave {
return nil
}

defer p.mu.Unlock()

file, err := os.Create(p.filePath)
if err != nil {
return fmt.Errorf("failed to create file: %w", err)
Expand Down

0 comments on commit 5f3167a

Please sign in to comment.