|
25 | 25 | import java.io.ByteArrayInputStream;
|
26 | 26 | import java.io.IOException;
|
27 | 27 | import java.io.InputStreamReader;
|
28 |
| -import java.io.Reader; |
29 | 28 | import java.io.StringReader;
|
30 |
| -import java.nio.ByteBuffer; |
31 |
| -import java.nio.CharBuffer; |
32 | 29 | import java.nio.charset.Charset;
|
33 | 30 | import java.nio.charset.StandardCharsets;
|
34 | 31 | import java.util.Map;
|
@@ -85,15 +82,6 @@ JsonParser create(JsonFactory factory, Supplier<byte[]> bytesSupplier) throws IO
|
85 | 82 | StandardCharsets.UTF_8));
|
86 | 83 | }
|
87 | 84 | },
|
88 |
| - CHAR_READER() { |
89 |
| - @Override |
90 |
| - JsonParser create(JsonFactory factory, Supplier<byte[]> jsonSupplier) throws IOException { |
91 |
| - ByteBuffer byteBuffer = ByteBuffer.wrap(jsonSupplier.get()); |
92 |
| - CharBuffer charBuffer = Charset.forName("UTF-8").decode(byteBuffer); |
93 |
| - CharBufferReader charBufferReader = new CharBufferReader(charBuffer); |
94 |
| - return factory.createParser(charBufferReader); |
95 |
| - } |
96 |
| - }, |
97 | 85 | STRING_READER() {
|
98 | 86 | @Override
|
99 | 87 | JsonParser create(JsonFactory factory, Supplier<byte[]> jsonSupplier) throws IOException {
|
@@ -200,68 +188,6 @@ public static final class SimpleClass {
|
200 | 188 | public String stringThree;
|
201 | 189 | }
|
202 | 190 |
|
203 |
| - public static class CharBufferReader extends Reader { |
204 |
| - private final CharBuffer charBuffer; |
205 |
| - |
206 |
| - public CharBufferReader(CharBuffer buffer) { |
207 |
| - this.charBuffer = buffer.duplicate(); |
208 |
| - } |
209 |
| - |
210 |
| - @Override |
211 |
| - public int read(char[] chars, int off, int len) { |
212 |
| - int remaining = this.charBuffer.remaining(); |
213 |
| - if (remaining <= 0) { |
214 |
| - return -1; |
215 |
| - } |
216 |
| - int length = Math.min(len, remaining); |
217 |
| - this.charBuffer.get(chars, off, length); |
218 |
| - return length; |
219 |
| - } |
220 |
| - |
221 |
| - @Override |
222 |
| - public int read() { |
223 |
| - if (this.charBuffer.hasRemaining()) { |
224 |
| - return this.charBuffer.get(); |
225 |
| - } |
226 |
| - return -1; |
227 |
| - } |
228 |
| - |
229 |
| - @Override |
230 |
| - public long skip(long n) { |
231 |
| - if (n < 0L) { |
232 |
| - throw new IllegalArgumentException("number of characters to skip cannot be negative"); |
233 |
| - } |
234 |
| - int skipped = Math.min((int) n, this.charBuffer.remaining()); |
235 |
| - this.charBuffer.position(this.charBuffer.position() + skipped); |
236 |
| - return skipped; |
237 |
| - } |
238 |
| - |
239 |
| - @Override |
240 |
| - public boolean ready() { |
241 |
| - return true; |
242 |
| - } |
243 |
| - |
244 |
| - @Override |
245 |
| - public boolean markSupported() { |
246 |
| - return true; |
247 |
| - } |
248 |
| - |
249 |
| - @Override |
250 |
| - public void mark(int readAheadLimit) { |
251 |
| - this.charBuffer.mark(); |
252 |
| - } |
253 |
| - |
254 |
| - @Override |
255 |
| - public void reset() { |
256 |
| - this.charBuffer.reset(); |
257 |
| - } |
258 |
| - |
259 |
| - @Override |
260 |
| - public void close() { |
261 |
| - this.charBuffer.position(this.charBuffer.limit()); |
262 |
| - } |
263 |
| - } |
264 |
| - |
265 | 191 | public static void main(String[] _args) throws Exception {
|
266 | 192 | new Runner(new OptionsBuilder()
|
267 | 193 | .include(JsonArbitraryFieldNameBenchmark.class.getName())
|
|
0 commit comments