Skip to content

Commit 1d17119

Browse files
committed
use pointer to struct to reduce allocations
1 parent 585d285 commit 1d17119

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

extensions/autolink_pages/autolink_pages.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,23 @@ type NormalizedPage struct {
2424
normalizedName string
2525
}
2626

27-
type fileInfoByNameLength []NormalizedPage
27+
type fileInfoByNameLength []*NormalizedPage
2828

2929
func (a fileInfoByNameLength) Len() int { return len(a) }
3030
func (a fileInfoByNameLength) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
3131
func (a fileInfoByNameLength) Less(i, j int) bool {
3232
return len(a[i].normalizedName) > len(a[j].normalizedName)
3333
}
3434

35-
var autolinkPages []NormalizedPage
35+
var autolinkPages []*NormalizedPage
3636
var autolinkPage_lck sync.Mutex
3737

3838
func UpdatePagesList(Page) (err error) {
3939
autolinkPage_lck.Lock()
4040
defer autolinkPage_lck.Unlock()
4141

42-
ps := MapPage(context.Background(), func(p Page) NormalizedPage {
43-
return NormalizedPage{
42+
ps := MapPage(context.Background(), func(p Page) *NormalizedPage {
43+
return &NormalizedPage{
4444
page: p,
4545
normalizedName: strings.ToLower(p.Name()),
4646
}

0 commit comments

Comments
 (0)