From 247a23a6377e36ee31f9a9189f670c836dcab200 Mon Sep 17 00:00:00 2001 From: Tao Wen Date: Thu, 5 Jan 2017 09:16:41 +0800 Subject: [PATCH] remove skipWhitespaces --- jsoniter_adapter.go => feature_adapter.go | 0 any.go => feature_any.go | 0 jsoniter_reflect.go => feature_reflect.go | 0 jsoniter.go | 25 +---------------------- 4 files changed, 1 insertion(+), 24 deletions(-) rename jsoniter_adapter.go => feature_adapter.go (100%) rename any.go => feature_any.go (100%) rename jsoniter_reflect.go => feature_reflect.go (100%) diff --git a/jsoniter_adapter.go b/feature_adapter.go similarity index 100% rename from jsoniter_adapter.go rename to feature_adapter.go diff --git a/any.go b/feature_any.go similarity index 100% rename from any.go rename to feature_any.go diff --git a/jsoniter_reflect.go b/feature_reflect.go similarity index 100% rename from jsoniter_reflect.go rename to feature_reflect.go diff --git a/jsoniter.go b/jsoniter.go index 8382689..e4dc849 100644 --- a/jsoniter.go +++ b/jsoniter.go @@ -76,7 +76,6 @@ func Parse(reader io.Reader, bufSize int) *Iterator { head: 0, tail: 0, } - iter.skipWhitespaces() return iter } @@ -87,7 +86,6 @@ func ParseBytes(input []byte) *Iterator { head: 0, tail: len(input), } - iter.skipWhitespaces() return iter } @@ -99,7 +97,6 @@ func (iter *Iterator) Reset(reader io.Reader) *Iterator { iter.reader = reader iter.head = 0 iter.tail = 0 - iter.skipWhitespaces() return iter } @@ -110,7 +107,6 @@ func (iter *Iterator) ResetBytes(input []byte) *Iterator { iter.buf = input iter.head = 0 iter.tail = len(input) - iter.skipWhitespaces() return iter } @@ -120,23 +116,6 @@ func (iter *Iterator) WhatIsNext() ValueType { return valueType; } -func (iter *Iterator) skipWhitespaces() { - for { - for i := iter.head; i < iter.tail; i++ { - c := iter.buf[i] - switch c { - case ' ', '\n', '\t', '\r': - continue - } - iter.head = i - return - } - if !iter.loadMore() { - return - } - } -} - func (iter *Iterator) skipWhitespacesWithoutLoadMore() bool { for i := iter.head; i < iter.tail; i++ { c := iter.buf[i] @@ -370,7 +349,7 @@ func (iter *Iterator) ReadString() (ret string) { func (iter *Iterator) readStringAsBytes() (ret []byte) { - c := iter.readByte() + c := iter.nextToken() if c == 'n' { iter.skipUntilBreak() return @@ -560,7 +539,6 @@ func (iter *Iterator) ReadArray() (ret bool) { } case ']': return false case ',': - iter.skipWhitespaces() return true default: iter.ReportError("ReadArray", "expect [ or , or ] or n") @@ -598,7 +576,6 @@ func (iter *Iterator) ReadObject() (ret string) { } } case ',': - iter.skipWhitespaces() return iter.readObjectField() case '}': return "" // end of object