From 71bfb895e509e6558b517c11eb211dcd1cc4a7b6 Mon Sep 17 00:00:00 2001 From: xfy Date: Thu, 4 Jun 2026 10:45:11 +0800 Subject: [PATCH] perf(loadbalance): delegate fnvHash64a to internal/hash Eliminates code duplication, uses shared inline FNV-1a implementation. --- internal/loadbalance/balancer.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/internal/loadbalance/balancer.go b/internal/loadbalance/balancer.go index 1bf1fda..e54f133 100644 --- a/internal/loadbalance/balancer.go +++ b/internal/loadbalance/balancer.go @@ -22,6 +22,8 @@ import ( "sync" "sync/atomic" "time" + + "rua.plus/lolly/internal/hash" ) type filterContext struct { @@ -55,12 +57,7 @@ func releaseFilterContext(fc *filterContext) { } func fnvHash64a(key string) uint64 { - var h uint64 = 14695981039346656037 - for i := 0; i < len(key); i++ { - h ^= uint64(key[i]) - h *= 1099511628211 - } - return h + return hash.FNV64a(key) } // Target 表示 HTTP 代理(L7 层)的负载均衡后端服务器目标。