Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7574e35

Browse files
committed
Replace the concurrent map with an identical upstream version
1 parent 9276660 commit 7574e35

6 files changed

Lines changed: 16 additions & 216 deletions

File tree

common/hmaps/map.go

Lines changed: 0 additions & 129 deletions
This file was deleted.

common/hmaps/map_test.go

Lines changed: 0 additions & 72 deletions
This file was deleted.

hugolib/content_map_page_assembler.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
"strings"
2222
"time"
2323

24+
"github.com/bep/helpers/maphelpers"
2425
"github.com/gohugoio/go-radix"
25-
"github.com/gohugoio/hugo/common/hmaps"
2626
"github.com/gohugoio/hugo/common/paths"
2727
"github.com/gohugoio/hugo/common/types"
2828
"github.com/gohugoio/hugo/hugofs/files"
@@ -54,9 +54,9 @@ type allPagesAssembler struct {
5454
rwRoot *doctree.NodeShiftTreeWalker[contentNode] // walks resources.
5555

5656
// Walking state.
57-
seenTerms *hmaps.Map[term, sitesmatrix.Vectors]
58-
droppedPages *hmaps.Map[*Site, []string] // e.g. drafts, expired, future.
59-
seenRootSections *hmaps.Map[string, bool]
57+
seenTerms *maphelpers.ConcurrentMap[term, sitesmatrix.Vectors]
58+
droppedPages *maphelpers.ConcurrentMap[*Site, []string] // e.g. drafts, expired, future.
59+
seenRootSections *maphelpers.ConcurrentMap[string, bool]
6060
seenHome bool // set before we fan out to multiple goroutines.
6161
}
6262

@@ -75,16 +75,16 @@ func newAllPagesAssembler(
7575
pw := rw.Extend()
7676
pw.Tree = m.treePages
7777

78-
seenRootSections := hmaps.NewMap[string, bool]()
78+
seenRootSections := maphelpers.NewConcurrentMap[string, bool]()
7979
seenRootSections.Set("", true) // home.
8080

8181
return &allPagesAssembler{
8282
ctx: ctx,
8383
h: h,
8484
m: m,
8585
assembleChanges: assembleChanges,
86-
seenTerms: hmaps.NewMap[term, sitesmatrix.Vectors](),
87-
droppedPages: hmaps.NewMap[*Site, []string](),
86+
seenTerms: maphelpers.NewConcurrentMap[term, sitesmatrix.Vectors](),
87+
droppedPages: maphelpers.NewConcurrentMap[*Site, []string](),
8888
seenRootSections: seenRootSections,
8989
assembleSectionsInParallel: !h.isRebuild(), // On partial rebuilds, there's potential data races with parallel section assembly.
9090
pwRoot: pw,

hugolib/hugo_sites.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"sync/atomic"
2626
"time"
2727

28+
"github.com/bep/helpers/maphelpers"
2829
"github.com/bep/logg"
2930
"github.com/gohugoio/go-radix"
3031
"github.com/gohugoio/hugo/cache/dynacache"
@@ -99,8 +100,8 @@ type HugoSites struct {
99100
translationKeyPages *hmaps.SliceCache[page.Page]
100101

101102
pageTrees *pageTrees
102-
previousPageTreesWalkContext *doctree.WalkContext[contentNode] // Set for rebuilds only.
103-
previousSeenTerms *hmaps.Map[term, sitesmatrix.Vectors] // Set for rebuilds only.
103+
previousPageTreesWalkContext *doctree.WalkContext[contentNode] // Set for rebuilds only.
104+
previousSeenTerms *maphelpers.ConcurrentMap[term, sitesmatrix.Vectors] // Set for rebuilds only.
104105

105106
printUnusedTemplatesInit sync.Once
106107
printPathWarningsInit sync.Once

internal/warpc/warpc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ import (
2828
"sync/atomic"
2929
"time"
3030

31+
"github.com/bep/helpers/maphelpers"
3132
"github.com/bep/textandbinarywriter"
3233

33-
"github.com/gohugoio/hugo/common/hmaps"
3434
"github.com/gohugoio/hugo/common/hstrings"
3535
"github.com/gohugoio/hugo/common/hugio"
3636
"golang.org/x/sync/errgroup"
@@ -253,7 +253,7 @@ func (d *dispatcher[Q, R]) newCall(q Message[Q]) (*call[Q, R], error) {
253253
if err := q.init(); err != nil {
254254
return nil, err
255255
}
256-
responseKinds := hmaps.NewMap[string, bool]()
256+
responseKinds := maphelpers.NewConcurrentMap[string, bool]()
257257
for _, rk := range q.Header.ResponseKinds {
258258
responseKinds.Set(rk, true)
259259
}
@@ -424,7 +424,7 @@ func (d *dispatcher[Q, R]) pendingCall(id uint32) *call[Q, R] {
424424
type call[Q, R any] struct {
425425
request Message[Q]
426426
response Message[R]
427-
responseKinds *hmaps.Map[string, bool]
427+
responseKinds *maphelpers.ConcurrentMap[string, bool]
428428
err error
429429
donec chan *call[Q, R]
430430
}

resources/resource_cache.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"strings"
2323
"sync"
2424

25-
"github.com/gohugoio/hugo/common/hmaps"
25+
"github.com/bep/helpers/maphelpers"
2626
"github.com/gohugoio/hugo/resources/resource"
2727

2828
"github.com/gohugoio/hugo/cache/dynacache"
@@ -58,7 +58,7 @@ func newResourceCache(rs *Spec, memCache *dynacache.Cache) *ResourceCache {
5858
dynacache.OptionsPartition{ClearWhen: dynacache.ClearOnChange, Weight: 40},
5959
),
6060

61-
cacheResourceTransformationPublished: hmaps.NewMap[string, string](),
61+
cacheResourceTransformationPublished: maphelpers.NewConcurrentMap[string, string](),
6262
}
6363
}
6464

@@ -72,7 +72,7 @@ type ResourceCache struct {
7272
cacheResourceTransformation *dynacache.Partition[string, *resourceAdapterInner]
7373

7474
// Used in rebuilds. Maps the target path to the last published transformation key.
75-
cacheResourceTransformationPublished *hmaps.Map[string, string]
75+
cacheResourceTransformationPublished *maphelpers.ConcurrentMap[string, string]
7676

7777
fileCache *filecache.Cache
7878
}

0 commit comments

Comments
 (0)