Skip to content

Commit c8d0683

Browse files
myleshortonCopilot
andauthored
Update front.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 46a233d commit c8d0683

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

front.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -377,32 +377,32 @@ func (m sortedFronts) Less(i, j int) bool {
377377
}
378378
}
379379

380-
func (m *sortedFronts) sortedCopy() sortedFronts {
381-
c := make(sortedFronts, len(*m))
382-
frontsMu.Lock()
383-
defer frontsMu.Unlock()
384-
copy(c, *m)
385-
sort.Sort(c)
380+
func (m *sortedFronts) sortedCopy() []Front {
381+
m.mu.Lock()
382+
defer m.mu.Unlock()
383+
c := make([]Front, len(m.fronts))
384+
copy(c, m.fronts)
385+
sort.Sort(sortedFronts{fronts: c})
386386
return c
387387
}
388388

389-
func (m *sortedFronts) addFronts(fronts sortedFronts) {
389+
func (m *sortedFronts) addFronts(fronts []Front) {
390390
// Add new masquerades to the existing masquerades slice, but add them at the beginning.
391-
frontsMu.Lock()
392-
defer frontsMu.Unlock()
393-
*m = append(fronts, *m...)
391+
m.mu.Lock()
392+
defer m.mu.Unlock()
393+
m.fronts = append(fronts, m.fronts...)
394394
}
395395

396396
func (m *sortedFronts) size() int {
397-
frontsMu.Lock()
398-
defer frontsMu.Unlock()
399-
return len(*m)
397+
m.mu.Lock()
398+
defer m.mu.Unlock()
399+
return len(m.fronts)
400400
}
401401

402402
func (m *sortedFronts) frontAt(i int) Front {
403-
frontsMu.Lock()
404-
defer frontsMu.Unlock()
405-
return (*m)[i]
403+
m.mu.Lock()
404+
defer m.mu.Unlock()
405+
return m.fronts[i]
406406
}
407407

408408
func (fr *front) markCacheDirty() {

0 commit comments

Comments
 (0)