Skip to content

Commit f532de6

Browse files
committed
remove unused code
1 parent 4d73f34 commit f532de6

File tree

4 files changed

+28
-143
lines changed

4 files changed

+28
-143
lines changed

src/main/java/com/alibaba/fastjson/JSONWriter.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -182,24 +182,4 @@ public void flush() throws IOException {
182182
public void close() throws IOException {
183183
writer.close();
184184
}
185-
186-
@Deprecated
187-
public void writeStartObject() {
188-
startObject();
189-
}
190-
191-
@Deprecated
192-
public void writeEndObject() {
193-
endObject();
194-
}
195-
196-
@Deprecated
197-
public void writeStartArray() {
198-
startArray();
199-
}
200-
201-
@Deprecated
202-
public void writeEndArray() {
203-
endArray();
204-
}
205185
}

src/main/java/com/alibaba/fastjson/util/IOUtils.java

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@
1616
package com.alibaba.fastjson.util;
1717

1818
import java.io.Closeable;
19-
import java.nio.ByteBuffer;
20-
import java.nio.CharBuffer;
21-
import java.nio.charset.CharacterCodingException;
22-
import java.nio.charset.CharsetDecoder;
23-
import java.nio.charset.CoderResult;
24-
25-
import com.alibaba.fastjson.JSONException;
2619

2720
/**
2821
* @author wenshao[szujobs@hotmail.com]
@@ -204,70 +197,6 @@ public static void getChars(long i, int index, char[] buf) {
204197
}
205198
}
206199

207-
/**
208-
* Places characters representing the integer i into the character array buf. The characters are placed into the
209-
* buffer backwards starting with the least significant digit at the specified index (exclusive), and working
210-
* backwards from there. Will fail if i == Integer.MIN_VALUE
211-
*/
212-
public static void getChars(int i, int index, char[] buf) {
213-
int q, r;
214-
int charPos = index;
215-
char sign = 0;
216-
217-
if (i < 0) {
218-
sign = '-';
219-
i = -i;
220-
}
221-
222-
// Generate two digits per iteration
223-
while (i >= 65536) {
224-
q = i / 100;
225-
// really: r = i - (q * 100);
226-
r = i - ((q << 6) + (q << 5) + (q << 2));
227-
i = q;
228-
buf[--charPos] = DigitOnes[r];
229-
buf[--charPos] = DigitTens[r];
230-
}
231-
232-
// Fall thru to fast mode for smaller numbers
233-
// assert(i <= 65536, i);
234-
for (;;) {
235-
q = (i * 52429) >>> (16 + 3);
236-
r = i - ((q << 3) + (q << 1)); // r = i-(q*10) ...
237-
buf[--charPos] = digits[r];
238-
i = q;
239-
if (i == 0) break;
240-
}
241-
if (sign != 0) {
242-
buf[--charPos] = sign;
243-
}
244-
}
245-
246-
public static void getChars(byte b, int index, char[] buf) {
247-
int i = b;
248-
int q, r;
249-
int charPos = index;
250-
char sign = 0;
251-
252-
if (i < 0) {
253-
sign = '-';
254-
i = -i;
255-
}
256-
257-
// Fall thru to fast mode for smaller numbers
258-
// assert(i <= 65536, i);
259-
for (;;) {
260-
q = (i * 52429) >>> (16 + 3);
261-
r = i - ((q << 3) + (q << 1)); // r = i-(q*10) ...
262-
buf[--charPos] = digits[r];
263-
i = q;
264-
if (i == 0) break;
265-
}
266-
if (sign != 0) {
267-
buf[--charPos] = sign;
268-
}
269-
}
270-
271200
/**
272201
* All possible chars for representing a number as a String
273202
*/
@@ -297,23 +226,4 @@ public static int stringSize(int x) {
297226
}
298227
}
299228

300-
public static void decode(CharsetDecoder charsetDecoder, ByteBuffer byteBuf, CharBuffer charByte) {
301-
try {
302-
CoderResult cr = charsetDecoder.decode(byteBuf, charByte, true);
303-
304-
if (!cr.isUnderflow()) {
305-
cr.throwException();
306-
}
307-
308-
cr = charsetDecoder.flush(charByte);
309-
310-
if (!cr.isUnderflow()) {
311-
cr.throwException();
312-
}
313-
} catch (CharacterCodingException x) {
314-
// Substitution is always enabled,
315-
// so this shouldn't happen
316-
throw new JSONException(x.getMessage(), x);
317-
}
318-
}
319229
}

src/test/java/com/alibaba/json/bvt/JSONWriterTest.java

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public void test_0() throws Exception {
1414
StringWriter out = new StringWriter();
1515

1616
JSONWriter writer = new JSONWriter(out);
17-
writer.writeStartObject();
18-
writer.writeEndObject();
17+
writer.startObject();
18+
writer.endObject();
1919
writer.flush();
2020

2121
Assert.assertEquals("{}", out.toString());
@@ -25,10 +25,10 @@ public void test_1() throws Exception {
2525
StringWriter out = new StringWriter();
2626

2727
JSONWriter writer = new JSONWriter(out);
28-
writer.writeStartObject();
28+
writer.startObject();
2929
writer.writeKey("id");
3030
writer.writeValue(33);
31-
writer.writeEndObject();
31+
writer.endObject();
3232
writer.flush();
3333

3434
Assert.assertEquals("{\"id\":33}", out.toString());
@@ -38,15 +38,15 @@ public void test_2() throws Exception {
3838
StringWriter out = new StringWriter();
3939

4040
JSONWriter writer = new JSONWriter(out);
41-
writer.writeStartObject();
41+
writer.startObject();
4242

4343
writer.writeKey("id");
4444
writer.writeValue(33);
4545

4646
writer.writeKey("name");
4747
writer.writeValue("jobs");
4848

49-
writer.writeEndObject();
49+
writer.endObject();
5050
writer.flush();
5151

5252
Assert.assertEquals("{\"id\":33,\"name\":\"jobs\"}", out.toString());
@@ -56,7 +56,7 @@ public void test_3() throws Exception {
5656
StringWriter out = new StringWriter();
5757

5858
JSONWriter writer = new JSONWriter(out);
59-
writer.writeStartObject();
59+
writer.startObject();
6060

6161
writer.writeKey("id");
6262
writer.writeValue(33);
@@ -65,17 +65,17 @@ public void test_3() throws Exception {
6565
writer.writeValue("jobs");
6666

6767
writer.writeKey("children");
68-
writer.writeStartArray();
68+
writer.startArray();
6969

70-
writer.writeStartObject();
71-
writer.writeEndObject();
70+
writer.startObject();
71+
writer.endObject();
7272

73-
writer.writeStartObject();
74-
writer.writeEndObject();
73+
writer.startObject();
74+
writer.endObject();
7575

76-
writer.writeEndArray();
76+
writer.endArray();
7777

78-
writer.writeEndObject();
78+
writer.endObject();
7979
writer.flush();
8080

8181
Assert.assertEquals("{\"id\":33,\"name\":\"jobs\",\"children\":[{},{}]}", out.toString());
@@ -86,31 +86,31 @@ public void test_4() throws Exception {
8686

8787
JSONWriter writer = new JSONWriter(out);
8888

89-
writer.writeStartArray();
89+
writer.startArray();
9090

91-
writer.writeStartObject();
92-
writer.writeEndObject();
91+
writer.startObject();
92+
writer.endObject();
9393

94-
writer.writeStartObject();
95-
writer.writeEndObject();
94+
writer.startObject();
95+
writer.endObject();
9696

97-
writer.writeStartArray();
98-
writer.writeEndArray();
97+
writer.startArray();
98+
writer.endArray();
9999
{
100-
writer.writeStartArray();
100+
writer.startArray();
101101

102-
writer.writeStartArray();
103-
writer.writeEndArray();
102+
writer.startArray();
103+
writer.endArray();
104104

105-
writer.writeStartArray();
106-
writer.writeEndArray();
105+
writer.startArray();
106+
writer.endArray();
107107

108-
writer.writeEndArray();
108+
writer.endArray();
109109

110110
writer.writeValue(1);
111111
}
112112

113-
writer.writeEndArray();
113+
writer.endArray();
114114

115115
writer.flush();
116116

src/test/java/com/alibaba/json/bvt/serializer/ByteArraySerializerTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010

1111
public class ByteArraySerializerTest extends TestCase {
1212

13-
public void test_b_0() {
14-
char[] buf = new char[4];
15-
IOUtils.getChars((byte) -127, 4, buf);
16-
}
17-
1813
public void test_0() {
1914
Assert.assertEquals("\"\"", JSON.toJSONString(new byte[0]));
2015
Assert.assertEquals("\"AQI=\"", JSON.toJSONString(new byte[] { 1, 2 }));

0 commit comments

Comments
 (0)