Browse Source

create new input slice and replace

Bruce MacDonald 2 tháng trước cách đây
mục cha
commit
6835f58c63
1 tập tin đã thay đổi với 4 bổ sung1 xóa
  1. 4 1
      runner/llamarunner/cache.go

+ 4 - 1
runner/llamarunner/cache.go

@@ -258,7 +258,10 @@ func (c *InputCache) ShiftCacheSlot(slot *InputCacheSlot, numKeep int) error {
 		copy(afterDiscardInputs, slot.Inputs[numKeep+discard:])
 
 		// Update the inputs to match what would happen after a shift
-		slot.Inputs = append(keepInputs, afterDiscardInputs...)
+		newInputs := make([]input, 0, numKeep+len(afterDiscardInputs))
+		newInputs = append(newInputs, keepInputs...)
+		newInputs = append(newInputs, afterDiscardInputs...)
+		slot.Inputs = newInputs
 	}
 
 	return nil