Skip to content

maybe compatible with go1.10? #240

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

Closed
deafwolf opened this issue Feb 22, 2018 · 4 comments
Closed

maybe compatible with go1.10? #240

deafwolf opened this issue Feb 22, 2018 · 4 comments

Comments

@deafwolf
Copy link

go 1.10 was released with strings.Builder, maybe jsoniter could use it for more faster and avoid panic.

@taowen
Copy link
Contributor

taowen commented Feb 22, 2018

@deafwolf
Copy link
Author

faster: yes, but not enough. what about refact the Stream? there is a []byte in it
avoid panic: I had saw someone report panic #233 without test code, maybe it was cause by using unsafe, so I think official Builder is a little safer.

@taowen
Copy link
Contributor

taowen commented Feb 22, 2018

unsafe will not cause panic. incorrect use of unsafe will. The new implementation has incorporated reflect2 package, which copies the underlying code from golang reflect implementation. A couple of incorrect usage of unsafe has been eliminated.

For marshaling into stream, the []byte is necessary. We can not cast string to []byte and write to writer. For two reasons: the string might contain character need escape, which means the []byte will be different. Second, flushing to writer should be buffered, the syscall itself is also expensive.

@deafwolf
Copy link
Author

ok, got it.

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