OSDN Git Service

git-svn-id: http://www.xerial.org/svn/project/XerialJ/trunk/xerial-core@3348 ae02f08e...
authorleo <leo@ae02f08e-27ec-0310-ae8c-8ba02fe2eafd>
Mon, 1 Jun 2009 09:46:35 +0000 (09:46 +0000)
committerleo <leo@ae02f08e-27ec-0310-ae8c-8ba02fe2eafd>
Mon, 1 Jun 2009 09:46:35 +0000 (09:46 +0000)
src/main/java/org/xerial/json/JSONArray.java

index 8c6d2ce..3395287 100644 (file)
@@ -39,24 +39,20 @@ import org.xerial.json.impl.JSONTokenizer;
 public class JSONArray extends JSONValueBase implements Iterable<JSONValue>\r
 {\r
 \r
-    private final ArrayList<JSONValue> _array;\r
+    private final ArrayList<JSONValue> _array = new ArrayList<JSONValue>();\r
 \r
     public JSONArray()\r
-    {\r
-        _array = new ArrayList<JSONValue>();\r
-    }\r
+    {}\r
 \r
     public JSONArray(List<JSONValue> elemList)\r
     {\r
-        _array = new ArrayList<JSONValue>(elemList.size());\r
+        _array.ensureCapacity(elemList.size());\r
         for (JSONValue v : elemList)\r
             _array.add(v);\r
     }\r
 \r
     JSONArray(JSONPullParser parser) throws JSONException\r
     {\r
-        this._array = new ArrayList<JSONValue>();\r
-\r
         JSONEvent e = parser.next();\r
         if (e != JSONEvent.StartArray)\r
             throw new JSONException(JSONErrorCode.ParseError, "expected [, but " + e);\r
@@ -139,7 +135,6 @@ public class JSONArray extends JSONValueBase implements Iterable<JSONValue>
 \r
     public JSONArray(JSONTokenizer tokenizer) throws JSONException\r
     {\r
-        _array = new ArrayList<JSONValue>();\r
 \r
         char c = tokenizer.nextClean();\r
         char q;\r