Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
CrisisTM opened this issue Mar 6, 2019 · 2 comments
Open

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

CrisisTM opened this issue Mar 6, 2019 · 2 comments

Comments

@CrisisTM
Copy link

CrisisTM commented Mar 6, 2019

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

@awsong
Copy link
Owner

awsong commented Sep 23, 2019

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.

@wxf4150
Copy link

wxf4150 commented Mar 7, 2023

go-darts/darts.go

Lines 74 to 84 in 1b63d94

func (d *dartsBuild) resize(newSize int) {
if newSize > cap(d.darts.Base) {
d.darts.Base = append(d.darts.Base, make([]int, (newSize-len(d.darts.Base)))...)
d.darts.Check = append(d.darts.Check, make([]int, (newSize-len(d.darts.Check)))...)
d.used = append(d.used, make([]bool, (newSize-len(d.used)))...)
} else {
d.darts.Base = d.darts.Base[:newSize]
d.darts.Check = d.darts.Check[:newSize]
d.used = d.used[:newSize]
}
}

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants