mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
patch a low level bug in EnsureCapacity
Former-commit-id: 2d50dc6923e7cfca9b864fb885577c1d1f936fc1
This commit is contained in:
@ -88,8 +88,19 @@ func (s *BioSequenceSlice) EnsureCapacity(capacity int) *BioSequenceSlice {
|
||||
c = 0
|
||||
}
|
||||
|
||||
if capacity > c {
|
||||
*s = slices.Grow[BioSequenceSlice](*s, capacity-c)
|
||||
n := 0
|
||||
for capacity > c {
|
||||
old_c := c
|
||||
*s = slices.Grow(*s, capacity)
|
||||
c = cap(*s)
|
||||
if c < capacity {
|
||||
n++
|
||||
if n < 4 {
|
||||
log.Warnf("cannot allocate a Biosequence Slice of size %d (only %d from %d)", capacity, c, old_c)
|
||||
} else {
|
||||
log.Panicf("cannot allocate a Biosequence Slice of size %d (only %d from %d)", capacity, c, old_c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s
|
||||
|
@ -138,7 +138,6 @@ func FindGeomClosest(sequence *obiseq.BioSequence,
|
||||
}
|
||||
|
||||
matches := obiseq.MakeBioSequenceSlice(len(min_idx))
|
||||
matches = matches[0:len(min_idx)]
|
||||
for i, j := range min_idx {
|
||||
matches[i] = (*references)[j]
|
||||
}
|
||||
|
Reference in New Issue
Block a user