Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ozanh
Copy link
Contributor

@ozanh ozanh commented May 4, 2020

Newly introduced stringEncode function fixes json module's unicode string encoding bug and closes #268
This implementation interestingly looks faster than strconv.AppendQuote() for very small set of strings. Benchmark results are below

goos: linux
goarch: amd64
pkg: github.com/d5/tengo/v2/stdlib/json
BenchmarkStringEncodeASCII
BenchmarkStringEncodeASCII   	 5040517	       227 ns/op	     192 B/op
BenchmarkStringEncodeUnicode
BenchmarkStringEncodeUnicode 	 4289095	       283 ns/op	     192 B/op
BenchmarkQuoteASCII
BenchmarkQuoteASCII          	 4939057	       235 ns/op	     335 B/op
BenchmarkQuoteUnicode
BenchmarkQuoteUnicode        	 2456857	       480 ns/op	     543 B/op

@d5
Copy link
Owner

d5 commented May 5, 2020

This is awesome!! @geseq let me know what you think!

Copy link
Collaborator

@geseq geseq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@geseq geseq merged commit 3d7269c into d5:master May 5, 2020
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

Successfully merging this pull request may close these issues.

json encode bug

3 participants