mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-01-25 16:18:27 +00:00
Remove unnecessary copy of Chunk slice
This commit is contained in:
parent
d4f3d5a164
commit
6725151a99
@ -79,15 +79,8 @@ func (cl *ChunkList) Snapshot() ([]*Chunk, int) {
|
|||||||
|
|
||||||
// Duplicate the last chunk
|
// Duplicate the last chunk
|
||||||
if cnt := len(ret); cnt > 0 {
|
if cnt := len(ret); cnt > 0 {
|
||||||
ret[cnt-1] = ret[cnt-1].dupe()
|
newChunk := *ret[cnt-1]
|
||||||
|
ret[cnt-1] = &newChunk
|
||||||
}
|
}
|
||||||
return ret, cl.count
|
return ret, cl.count
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Chunk) dupe() *Chunk {
|
|
||||||
newChunk := make(Chunk, len(*c))
|
|
||||||
for idx, ptr := range *c {
|
|
||||||
newChunk[idx] = ptr
|
|
||||||
}
|
|
||||||
return &newChunk
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user