From 77dcffe77d06c9d230ae1fc2d2da95bfa4364806 Mon Sep 17 00:00:00 2001 From: Tao Wen Date: Sat, 17 Jun 2017 22:42:11 +0800 Subject: [PATCH] tweak performance --- feature_iter_object.go | 9 +++++---- feature_pool.go | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/feature_iter_object.go b/feature_iter_object.go index 5a84b0f..5eb91e6 100644 --- a/feature_iter_object.go +++ b/feature_iter_object.go @@ -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 } } diff --git a/feature_pool.go b/feature_pool.go index 7f682dd..85170ff 100644 --- a/feature_pool.go +++ b/feature_pool.go @@ -1,6 +1,8 @@ package jsoniter -import "io" +import ( + "io" +) func (cfg *frozenConfig) BorrowStream(writer io.Writer) *Stream { select {