Skip to content

Commit fd27076

Browse files
committed
Instantiate other mutexes by value
Like in the previous commit, this is preferred because the fields don't need to be initialized this way.
1 parent 5ee5d42 commit fd27076

File tree

6 files changed

+9
-15
lines changed

6 files changed

+9
-15
lines changed

pkg/commands/git_commands/main_branches.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type MainBranches struct {
2121
previousMainBranches []string
2222

2323
cmd oscommands.ICmdObjBuilder
24-
mutex *deadlock.Mutex
24+
mutex deadlock.Mutex
2525
}
2626

2727
func NewMainBranches(
@@ -32,7 +32,6 @@ func NewMainBranches(
3232
c: cmn,
3333
existingMainBranches: nil,
3434
cmd: cmd,
35-
mutex: &deadlock.Mutex{},
3635
}
3736
}
3837

pkg/gui/context/filtered_list.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ type FilteredList[T any] struct {
1616
getFilterFields func(T) []string
1717
filter string
1818

19-
mutex *deadlock.Mutex
19+
mutex deadlock.Mutex
2020
}
2121

2222
func NewFilteredList[T any](getList func() []T, getFilterFields func(T) []string) *FilteredList[T] {
2323
return &FilteredList[T]{
2424
getList: getList,
2525
getFilterFields: getFilterFields,
26-
mutex: &deadlock.Mutex{},
2726
}
2827
}
2928

pkg/gui/context/merge_conflicts_context.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type MergeConflictsContext struct {
1212
types.Context
1313
viewModel *ConflictsViewModel
1414
c *ContextCommon
15-
mutex *deadlock.Mutex
15+
mutex deadlock.Mutex
1616
}
1717

1818
type ConflictsViewModel struct {
@@ -33,7 +33,6 @@ func NewMergeConflictsContext(
3333

3434
return &MergeConflictsContext{
3535
viewModel: viewModel,
36-
mutex: &deadlock.Mutex{},
3736
Context: NewSimpleContext(
3837
NewBaseContext(NewBaseContextOpts{
3938
Kind: types.MAIN_CONTEXT,
@@ -57,7 +56,7 @@ func (self *MergeConflictsContext) SetState(state *mergeconflicts.State) {
5756
}
5857

5958
func (self *MergeConflictsContext) GetMutex() *deadlock.Mutex {
60-
return self.mutex
59+
return &self.mutex
6160
}
6261

6362
func (self *MergeConflictsContext) SetUserScrolling(isScrolling bool) {

pkg/gui/context/patch_explorer_context.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type PatchExplorerContext struct {
1515
viewTrait *ViewTrait
1616
getIncludedLineIndices func() []int
1717
c *ContextCommon
18-
mutex *deadlock.Mutex
18+
mutex deadlock.Mutex
1919
}
2020

2121
var (
@@ -36,7 +36,6 @@ func NewPatchExplorerContext(
3636
state: nil,
3737
viewTrait: NewViewTrait(view),
3838
c: c,
39-
mutex: &deadlock.Mutex{},
4039
getIncludedLineIndices: getIncludedLineIndices,
4140
SimpleContext: NewSimpleContext(NewBaseContext(NewBaseContextOpts{
4241
View: view,
@@ -137,7 +136,7 @@ func (self *PatchExplorerContext) NavigateTo(selectedLineIdx int) {
137136
}
138137

139138
func (self *PatchExplorerContext) GetMutex() *deadlock.Mutex {
140-
return self.mutex
139+
return &self.mutex
141140
}
142141

143142
func (self *PatchExplorerContext) ModelSearchResults(searchStr string, caseSensitive bool) []gocui.SearchPosition {

pkg/gui/controllers/helpers/inline_status_helper.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@ type InlineStatusHelper struct {
1515

1616
windowHelper *WindowHelper
1717
contextsWithInlineStatus map[types.ContextKey]*inlineStatusInfo
18-
mutex *deadlock.Mutex
18+
mutex deadlock.Mutex
1919
}
2020

2121
func NewInlineStatusHelper(c *HelperCommon, windowHelper *WindowHelper) *InlineStatusHelper {
2222
return &InlineStatusHelper{
2323
c: c,
2424
windowHelper: windowHelper,
2525
contextsWithInlineStatus: make(map[types.ContextKey]*inlineStatusInfo),
26-
mutex: &deadlock.Mutex{},
2726
}
2827
}
2928

pkg/gui/gui.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ type Gui struct {
118118
// is being pushed). At the moment the rule is to use an item operation when
119119
// we need to talk to the remote.
120120
itemOperations map[string]types.ItemOperation
121-
itemOperationsMutex *deadlock.Mutex
121+
itemOperationsMutex deadlock.Mutex
122122

123123
PrevLayout PrevLayout
124124

@@ -684,8 +684,7 @@ func NewGui(
684684
InitialDir: initialDir,
685685
afterLayoutFuncs: make(chan func() error, 1000),
686686

687-
itemOperations: make(map[string]types.ItemOperation),
688-
itemOperationsMutex: &deadlock.Mutex{},
687+
itemOperations: make(map[string]types.ItemOperation),
689688
}
690689

691690
gui.PopupHandler = popup.NewPopupHandler(

0 commit comments

Comments
 (0)