perf: Use swap deletion
This commit is contained in:
@@ -687,9 +687,12 @@ func (t *GrepChunksTool) applyMMR(
|
|||||||
selected = append(selected, candidates[bestIdx])
|
selected = append(selected, candidates[bestIdx])
|
||||||
selectedTokenSets = append(selectedTokenSets, tokenSets[bestIdx])
|
selectedTokenSets = append(selectedTokenSets, tokenSets[bestIdx])
|
||||||
|
|
||||||
candidates = append(candidates[:bestIdx], candidates[bestIdx+1:]...)
|
// Remove corresponding token set. Use swap deletion
|
||||||
// Remove corresponding token set
|
last := len(candidates) - 1
|
||||||
tokenSets = append(tokenSets[:bestIdx], tokenSets[bestIdx+1:]...)
|
candidates[bestIdx] = candidates[last]
|
||||||
|
tokenSets[bestIdx] = tokenSets[last]
|
||||||
|
candidates = candidates[:last]
|
||||||
|
tokenSets = tokenSets[:last]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute average redundancy among selected results
|
// Compute average redundancy among selected results
|
||||||
|
|||||||
Reference in New Issue
Block a user