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:
parent
8ab46965bd
commit
77dcffe77d
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package jsoniter
|
||||
|
||||
import "io"
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
func (cfg *frozenConfig) BorrowStream(writer io.Writer) *Stream {
|
||||
select {
|
||||
|
Loading…
Reference in New Issue
Block a user