refactor: 将所有对象池升级为泛型实现

使用 Go 1.18+ 泛型特性优化对象池,提高类型安全性和性能。

- 将 bufPool 和 ctxPool 升级为使用已有的泛型池实现
- 移除所有 Get() 操作后的类型断言
- 保持 API 兼容性,确保现有代码无需大量修改
- 优化流数据传输中内存使用

性能改进:
- 减少运行时类型检查开销
- 消除了类型断言导致的潜在 panic 风险
- 优化了高并发场景下的内存分配模式
This commit is contained in:
2025-03-14 01:37:55 +08:00
parent 7affdc79c6
commit d423ed5029
4 changed files with 40 additions and 16 deletions

View File

@@ -52,7 +52,6 @@ func main() {
cfg.ReverseProxy = true
cfg.EnableCache = *enableCache
cfg.EnableCompression = *enableCompression
cfg.EnableURLRewrite = *enableRewrite
cfg.AddXForwardedFor = *addXForwardedFor
cfg.AddXRealIP = *addXRealIP
cfg.EnableCORS = *enableCORS