Skip to content

Commit

Permalink
🩹 Fix: dictpool is not completely gone (#2540)
Browse files Browse the repository at this point in the history
* Completely remove dictpool

Looks like issue:
#2209
Was not complete. So here dictpool is completely gone

* Fix linting error
  • Loading branch information
andre-dasilva authored Jul 11, 2023
1 parent a9933f5 commit 58270e2
Show file tree
Hide file tree
Showing 23 changed files with 12 additions and 59 deletions.
1 change: 0 additions & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_az.md
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@ Müəllif Hüququ (c) 2019-bugün [Fenny](https://github.com/fenny) və [Contrib
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_ckb.md
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@ For more articles, middlewares, examples or tools check our [awesome list](https
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_de.md
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_es.md
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ Copyright (c) 2019-presente [Fenny](https://github.com/fenny) y [contribuyentes]
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_fa.md
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_he.md
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_id.md
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_it.md
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@ Copyright (c) 2019-ora [Fenny](https://github.com/fenny) e [Contributors](https:
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_nl.md
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,6 @@ O logo oficial foi criado por [Vic Shóstak](https://github.com/koddr) e distrib
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,6 @@ Copyright (c) 2019-настоящее время [Fenny](https://github.com/fenn
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_sa.md
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_tr.md
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,6 @@ Telif (c) 2019-günümüz [Fenny](https://github.com/fenny) ve [katkıda bulunan
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_uk.md
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,6 @@ Fiber – це проект із відкритим вихідним кодом,
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,6 @@ Copyright (c) 2019-present [Fenny](https://github.com/fenny) and [Contributors](
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
1 change: 0 additions & 1 deletion .github/README_zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,6 @@ Fiber 是個仰賴捐款的開放原始碼專案——用來支付如域名、Gi
- [runewidth](https://github.com/mattn/go-runewidth/blob/master/LICENSE)
- [fasthttp](https://github.com/valyala/fasthttp/blob/master/LICENSE)
- [bytebufferpool](https://github.com/valyala/bytebufferpool/blob/master/LICENSE)
- [dictpool](https://github.com/savsgio/dictpool/blob/master/LICENSE)
- [fwd](https://github.com/philhofer/fwd/blob/master/LICENSE.md)
- [go-ole](https://github.com/go-ole/go-ole/blob/master/LICENSE)
- [gopsutil](https://github.com/shirou/gopsutil/blob/master/LICENSE)
Expand Down
30 changes: 12 additions & 18 deletions ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/gofiber/fiber/v2/internal/schema"
"github.com/gofiber/fiber/v2/utils"

"github.com/savsgio/dictpool"
"github.com/valyala/bytebufferpool"
"github.com/valyala/fasthttp"
)
Expand Down Expand Up @@ -97,7 +96,7 @@ type Ctx struct {
values [maxParams]string // Route parameter values
fasthttp *fasthttp.RequestCtx // Reference to *fasthttp.RequestCtx
matched bool // Non use route matched
viewBindMap *dictpool.Dict // Default view map to bind template engine
viewBindMap sync.Map // Default view map to bind template engine
}

// TLSHandler object
Expand Down Expand Up @@ -188,10 +187,7 @@ func (app *App) ReleaseCtx(c *Ctx) {
// Reset values
c.route = nil
c.fasthttp = nil
if c.viewBindMap != nil {
dictpool.ReleaseDict(c.viewBindMap)
c.viewBindMap = nil
}
c.viewBindMap = sync.Map{}
app.pool.Put(c)
}

Expand Down Expand Up @@ -1353,13 +1349,9 @@ func (c *Ctx) Redirect(location string, status ...int) error {
// Variables are read by the Render method and may be overwritten.
func (c *Ctx) Bind(vars Map) error {
// init viewBindMap - lazy map
if c.viewBindMap == nil {
c.viewBindMap = dictpool.AcquireDict()
}
for k, v := range vars {
c.viewBindMap.Set(k, v)
c.viewBindMap.Store(k, v)
}

return nil
}

Expand Down Expand Up @@ -1498,14 +1490,16 @@ func (c *Ctx) Render(name string, bind interface{}, layouts ...string) error {
func (c *Ctx) renderExtensions(bind interface{}) {
if bindMap, ok := bind.(Map); ok {
// Bind view map
if c.viewBindMap != nil {
for _, v := range c.viewBindMap.D {
// make sure key does not exist already
if _, ok := bindMap[v.Key]; !ok {
bindMap[v.Key] = v.Value
}
c.viewBindMap.Range(func(key, value interface{}) bool {
keyValue, ok := key.(string)
if !ok {
return true
}
}
if _, ok := bindMap[keyValue]; !ok {
bindMap[keyValue] = value
}
return true
})

// Check if the PassLocalsToViews option is enabled (by default it is disabled)
if c.app.config.PassLocalsToViews {
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/mattn/go-colorable v0.1.13
github.com/mattn/go-isatty v0.0.19
github.com/mattn/go-runewidth v0.0.14
github.com/savsgio/dictpool v0.0.0-20221023140959-7bf2e61cea94
github.com/tinylib/msgp v1.1.8
github.com/valyala/bytebufferpool v1.0.0
github.com/valyala/fasthttp v1.48.0
Expand All @@ -19,6 +18,5 @@ require (
github.com/klauspost/compress v1.16.3 // indirect
github.com/philhofer/fwd v1.1.2 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
)
Loading

0 comments on commit 58270e2

Please sign in to comment.