go-darts icon indicating copy to clipboard operation
go-darts copied to clipboard

Darts.go:75 cap func should be replaced by len func

Open CrisisTM opened this issue 5 years ago • 2 comments

if you wanna build a DA Trie with thousands of nodes, there may cause errors.

CrisisTM avatar Mar 06 '19 03:03 CrisisTM

Could you elaborate or give some test case? I intended to get the capacity of the slice, thus using cap func. Can't simply replace it with len func.

awsong avatar Sep 23 '19 00:09 awsong

https://github.com/awsong/go-darts/blob/1b63d94fdbea0f52b98c2d5ff42fb0b8f9de77b2/darts.go#L74-L84

"if newSize > cap(d.darts.Base) " 应该换成 if newSize > len(d.darts.Base) 。不改 TestExactMatchSearch测试都通不过。

wxf4150 avatar Mar 07 '23 03:03 wxf4150