1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-24 08:22:14 +02:00

tweak performance

This commit is contained in:
Tao Wen 2017-06-17 22:42:11 +08:00
parent 8ab46965bd
commit 77dcffe77d
2 changed files with 8 additions and 5 deletions

View File

@ -3,6 +3,7 @@ package jsoniter
import (
"fmt"
"unicode"
"unsafe"
)
func (iter *Iterator) ReadObject() (ret string) {
@ -79,13 +80,13 @@ func (iter *Iterator) ReadObjectCB(callback func(*Iterator, string) bool) bool {
c = iter.nextToken()
if c == '"' {
iter.unreadByte()
field := string(iter.readObjectFieldAsBytes())
if !callback(iter, field) {
field := iter.readObjectFieldAsBytes()
if !callback(iter, *(*string)(unsafe.Pointer(&field))) {
return false
}
for iter.nextToken() == ',' {
field = string(iter.readObjectFieldAsBytes())
if !callback(iter, field) {
field = iter.readObjectFieldAsBytes()
if !callback(iter, *(*string)(unsafe.Pointer(&field))) {
return false
}
}

View File

@ -1,6 +1,8 @@
package jsoniter
import "io"
import (
"io"
)
func (cfg *frozenConfig) BorrowStream(writer io.Writer) *Stream {
select {