fix to no prealloc (because max size unknown)

This commit is contained in:
Alex Sharov 2022-01-17 17:05:37 +07:00 committed by GitHub
parent fa6c709fcd
commit 7c2104e2e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -118,11 +118,11 @@ func (c *Compressor2) Compress() error {
go processSuperstring(superstrings, collector, c.minPatternScore, wg)
}
i := 0
c.superstring = make([]byte, 0, superstringLimit)
c.superstring = nil
if err := c.datFile.ForEach(func(word []byte) error {
if len(c.superstring)+2*len(word)+2 > superstringLimit {
superstrings <- c.superstring
c.superstring = make([]byte, 0, superstringLimit)
c.superstring = nil
}
for _, a := range word {
c.superstring = append(c.superstring, 1, a)