summaryrefslogtreecommitdiffstats
path: root/common/types
diff options
context:
space:
mode:
Diffstat (limited to 'common/types')
-rw-r--r--common/types/css/csstypes.go2
-rw-r--r--common/types/evictingqueue.go15
-rw-r--r--common/types/hstring/stringtypes.go2
-rw-r--r--common/types/hstring/stringtypes_test.go2
-rw-r--r--common/types/types.go13
5 files changed, 29 insertions, 5 deletions
diff --git a/common/types/css/csstypes.go b/common/types/css/csstypes.go
index a31df00e7..061acfe64 100644
--- a/common/types/css/csstypes.go
+++ b/common/types/css/csstypes.go
@@ -1,4 +1,4 @@
-// Copyright 2023 The Hugo Authors. All rights reserved.
+// Copyright 2024 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/common/types/evictingqueue.go b/common/types/evictingqueue.go
index 884762426..88add59d5 100644
--- a/common/types/evictingqueue.go
+++ b/common/types/evictingqueue.go
@@ -35,11 +35,11 @@ func NewEvictingStringQueue(size int) *EvictingStringQueue {
}
// Add adds a new string to the tail of the queue if it's not already there.
-func (q *EvictingStringQueue) Add(v string) {
+func (q *EvictingStringQueue) Add(v string) *EvictingStringQueue {
q.mu.Lock()
if q.set[v] {
q.mu.Unlock()
- return
+ return q
}
if len(q.set) == q.size {
@@ -50,6 +50,17 @@ func (q *EvictingStringQueue) Add(v string) {
q.set[v] = true
q.vals = append(q.vals, v)
q.mu.Unlock()
+
+ return q
+}
+
+func (q *EvictingStringQueue) Len() int {
+ if q == nil {
+ return 0
+ }
+ q.mu.Lock()
+ defer q.mu.Unlock()
+ return len(q.vals)
}
// Contains returns whether the queue contains v.
diff --git a/common/types/hstring/stringtypes.go b/common/types/hstring/stringtypes.go
index 601218e0e..5e8e3a23d 100644
--- a/common/types/hstring/stringtypes.go
+++ b/common/types/hstring/stringtypes.go
@@ -1,4 +1,4 @@
-// Copyright 2022 The Hugo Authors. All rights reserved.
+// Copyright 2024 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/common/types/hstring/stringtypes_test.go b/common/types/hstring/stringtypes_test.go
index 8fa1c9760..2f1f865c8 100644
--- a/common/types/hstring/stringtypes_test.go
+++ b/common/types/hstring/stringtypes_test.go
@@ -1,4 +1,4 @@
-// Copyright 2022 The Hugo Authors. All rights reserved.
+// Copyright 2024 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
diff --git a/common/types/types.go b/common/types/types.go
index c36c51b3e..11683c196 100644
--- a/common/types/types.go
+++ b/common/types/types.go
@@ -92,5 +92,18 @@ type DevMarker interface {
DevOnly()
}
+// Unwrapper is implemented by types that can unwrap themselves.
+type Unwrapper interface {
+ // Unwrapv is for internal use only.
+ // It got its slightly odd name to prevent collisions with user types.
+ Unwrapv() any
+}
+
+// LowHigh is typically used to represent a slice boundary.
+type LowHigh struct {
+ Low int
+ High int
+}
+
// This is only used for debugging purposes.
var InvocationCounter atomic.Int64