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

How to make the unmarshaling process of json int array faster? #572

Open
kuaikuai opened this issue Jan 4, 2024 · 1 comment
Open

How to make the unmarshaling process of json int array faster? #572

kuaikuai opened this issue Jan 4, 2024 · 1 comment

Comments

@kuaikuai
Copy link

kuaikuai commented Jan 4, 2024

sonic

code as the flow:
`func UnmarshalIntVector(size int, data string) ([]int32, error) {
if size < 0 {
return parseInt32(data)
}
var out []int32
if size > 0 {
out = make([]int32, 0, size)
}
err := sonic.UnmarshalString(data, &out)
if err != nil {
return nil, fmt.Errorf("UnmarshalIntVector json error: %s", err.Error())
}

if size == 0 {
	return out, nil
}
length := len(out)
if size != length {
	return nil, fmt.Errorf("UnmarshalIntVector needed size %d != len %d", size, length)
}

return out, nil

}`

@AsterDY
Copy link
Collaborator

AsterDY commented Jan 5, 2024

Didn't get what you mean. give more explaination

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

2 participants