Skip to content

Commit 91f7d28

Browse files
Update distribution/engine.go
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent ad8101f commit 91f7d28

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

distribution/engine.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ func (e *Engine) splitRange(idx int) {
125125
}
126126
left := Route{Start: r.Start, End: mid, GroupID: r.GroupID, Load: r.Load / 2}
127127
right := Route{Start: mid, End: r.End, GroupID: r.GroupID, Load: r.Load - (r.Load / 2)}
128-
e.routes = append(append(e.routes[:idx], left, right), e.routes[idx+1:]...)
128+
e.routes = append(e.routes, Route{}) // Make room for one more element.
129+
copy(e.routes[idx+2:], e.routes[idx+1:]) // Shift elements to the right.
130+
e.routes[idx] = left
131+
e.routes[idx+1] = right
129132
}
130133

131134
func cloneBytes(b []byte) []byte {

0 commit comments

Comments
 (0)