mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
chore: Use 'any' instead of 'interface{}' (#1666)
gofmt -w -r "interface{} -> any" -l .
This commit is contained in:
+4
-4
@@ -18,7 +18,7 @@ import (
|
||||
//
|
||||
// The stackless wrapper returns false if the call cannot be processed
|
||||
// at the moment due to high load.
|
||||
func NewFunc(f func(ctx interface{})) func(ctx interface{}) bool {
|
||||
func NewFunc(f func(ctx any)) func(ctx any) bool {
|
||||
if f == nil {
|
||||
// developer sanity-check
|
||||
panic("BUG: f cannot be nil")
|
||||
@@ -33,7 +33,7 @@ func NewFunc(f func(ctx interface{})) func(ctx interface{}) bool {
|
||||
}
|
||||
var once sync.Once
|
||||
|
||||
return func(ctx interface{}) bool {
|
||||
return func(ctx any) bool {
|
||||
once.Do(onceInit)
|
||||
fw := getFuncWork()
|
||||
fw.ctx = ctx
|
||||
@@ -50,7 +50,7 @@ func NewFunc(f func(ctx interface{})) func(ctx interface{}) bool {
|
||||
}
|
||||
}
|
||||
|
||||
func funcWorker(funcWorkCh <-chan *funcWork, f func(ctx interface{})) {
|
||||
func funcWorker(funcWorkCh <-chan *funcWork, f func(ctx any)) {
|
||||
for fw := range funcWorkCh {
|
||||
f(fw.ctx)
|
||||
fw.done <- struct{}{}
|
||||
@@ -75,6 +75,6 @@ func putFuncWork(fw *funcWork) {
|
||||
var funcWorkPool sync.Pool
|
||||
|
||||
type funcWork struct {
|
||||
ctx interface{}
|
||||
ctx any
|
||||
done chan struct{}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ func TestNewFuncSimple(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var n uint64
|
||||
f := NewFunc(func(ctx interface{}) {
|
||||
f := NewFunc(func(ctx any) {
|
||||
atomic.AddUint64(&n, uint64(ctx.(int)))
|
||||
})
|
||||
|
||||
@@ -30,10 +30,10 @@ func TestNewFuncMulti(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var n1, n2 uint64
|
||||
f1 := NewFunc(func(ctx interface{}) {
|
||||
f1 := NewFunc(func(ctx any) {
|
||||
atomic.AddUint64(&n1, uint64(ctx.(int)))
|
||||
})
|
||||
f2 := NewFunc(func(ctx interface{}) {
|
||||
f2 := NewFunc(func(ctx any) {
|
||||
atomic.AddUint64(&n2, uint64(ctx.(int)))
|
||||
})
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
func BenchmarkFuncOverhead(b *testing.B) {
|
||||
var n uint64
|
||||
f := NewFunc(func(ctx interface{}) {
|
||||
f := NewFunc(func(ctx any) {
|
||||
atomic.AddUint64(&n, *(ctx.(*uint64)))
|
||||
})
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
|
||||
+3
-3
@@ -101,17 +101,17 @@ var errHighLoad = errors.New("cannot compress data due to high load")
|
||||
|
||||
var (
|
||||
stacklessWriterFuncOnce sync.Once
|
||||
stacklessWriterFuncFunc func(ctx interface{}) bool
|
||||
stacklessWriterFuncFunc func(ctx any) bool
|
||||
)
|
||||
|
||||
func stacklessWriterFunc(ctx interface{}) bool {
|
||||
func stacklessWriterFunc(ctx any) bool {
|
||||
stacklessWriterFuncOnce.Do(func() {
|
||||
stacklessWriterFuncFunc = NewFunc(writerFunc)
|
||||
})
|
||||
return stacklessWriterFuncFunc(ctx)
|
||||
}
|
||||
|
||||
func writerFunc(ctx interface{}) {
|
||||
func writerFunc(ctx any) {
|
||||
w := ctx.(*writer)
|
||||
switch w.op {
|
||||
case opWrite:
|
||||
|
||||
Reference in New Issue
Block a user