Skip to content

Commit 1073c84

Browse files
committed
simplify code
1 parent 5ff5b99 commit 1073c84

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

demo/src/test/java/com/jsoniter/demo/ModelTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class ModelTest {
3232

3333
@Setup(Level.Trial)
3434
public void benchSetup(BenchmarkParams params) {
35-
JsonIterator.enableStreamingSupport();
35+
// JsonIterator.enableStreamingSupport();
3636
input = "{\"name\":\"wenshao\",\"id\":1001}";
3737
inputBytes = input.getBytes();
3838
iter = new JsonIterator();

src/main/java/com/jsoniter/IterImpl.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,23 @@
77
class IterImpl {
88

99
public static final int readObjectFieldAsHash(JsonIterator iter) throws IOException {
10-
if (IterImpl.nextToken(iter) != '"') {
10+
if (nextToken(iter) != '"') {
1111
throw iter.reportError("readObjectFieldAsHash", "expect \"");
1212
}
1313
long hash = 0x811c9dc5;
14-
for (; ; ) {
15-
byte c = 0;
16-
int i = iter.head;
17-
for (; i < iter.tail; i++) {
18-
c = iter.buf[i];
19-
if (c == '"') {
20-
break;
21-
}
22-
hash ^= c;
23-
hash *= 0x1000193;
24-
}
14+
for (int i = iter.head; i < iter.tail; i++) {
15+
byte c = iter.buf[i];
2516
if (c == '"') {
2617
iter.head = i + 1;
27-
if (IterImpl.nextToken(iter) != ':') {
18+
if (nextToken(iter) != ':') {
2819
throw iter.reportError("readObjectFieldAsHash", "expect :");
2920
}
3021
return (int) hash;
3122
}
32-
throw iter.reportError("readObjectFieldAsHash", "unmatched quote");
23+
hash ^= c;
24+
hash *= 0x1000193;
3325
}
26+
throw iter.reportError("readObjectFieldAsHash", "unmatched quote");
3427
}
3528

3629
public static final Slice readObjectFieldAsSlice(JsonIterator iter) throws IOException {
@@ -76,7 +69,7 @@ final static void skipObject(JsonIterator iter) throws IOException {
7669
switch (iter.buf[i]) {
7770
case '"': // If inside string, skip it
7871
iter.head = i + 1;
79-
IterImpl.skipString(iter);
72+
skipString(iter);
8073
i = iter.head - 1; // it will be i++ soon
8174
break;
8275
case '{': // If open symbol, increase level
@@ -190,7 +183,7 @@ public static Any readAny(JsonIterator iter) throws IOException {
190183
return Any.wrap(false);
191184
case 'n':
192185
skipUntilBreak(iter);
193-
return Any.wrap((Object)null);
186+
return Any.wrap((Object) null);
194187
case '[':
195188
skipArray(iter);
196189
return Any.lazyArray(iter.buf, start, iter.head);

0 commit comments

Comments
 (0)