mirror of
https://github.com/json-iterator/go.git
synced 2024-11-27 08:30:57 +02:00
tweak performance
This commit is contained in:
parent
8ab46965bd
commit
77dcffe77d
@ -3,6 +3,7 @@ package jsoniter
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (iter *Iterator) ReadObject() (ret string) {
|
func (iter *Iterator) ReadObject() (ret string) {
|
||||||
@ -79,13 +80,13 @@ func (iter *Iterator) ReadObjectCB(callback func(*Iterator, string) bool) bool {
|
|||||||
c = iter.nextToken()
|
c = iter.nextToken()
|
||||||
if c == '"' {
|
if c == '"' {
|
||||||
iter.unreadByte()
|
iter.unreadByte()
|
||||||
field := string(iter.readObjectFieldAsBytes())
|
field := iter.readObjectFieldAsBytes()
|
||||||
if !callback(iter, field) {
|
if !callback(iter, *(*string)(unsafe.Pointer(&field))) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for iter.nextToken() == ',' {
|
for iter.nextToken() == ',' {
|
||||||
field = string(iter.readObjectFieldAsBytes())
|
field = iter.readObjectFieldAsBytes()
|
||||||
if !callback(iter, field) {
|
if !callback(iter, *(*string)(unsafe.Pointer(&field))) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package jsoniter
|
package jsoniter
|
||||||
|
|
||||||
import "io"
|
import (
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
func (cfg *frozenConfig) BorrowStream(writer io.Writer) *Stream {
|
func (cfg *frozenConfig) BorrowStream(writer io.Writer) *Stream {
|
||||||
select {
|
select {
|
||||||
|
Loading…
Reference in New Issue
Block a user