You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by jw...@apache.org on 2016/04/24 18:16:45 UTC

[3/3] groovy git commit: refactor(json): inline to eliminate unused Classes (closes #318)

refactor(json): inline to eliminate unused Classes (closes #318)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/2cdba2f0
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/2cdba2f0
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/2cdba2f0

Branch: refs/heads/master
Commit: 2cdba2f01e00fca51e2725cb97e98cc72559f23d
Parents: 7d9af96
Author: John Wagenleitner <jw...@apache.org>
Authored: Fri Apr 22 23:08:34 2016 -0700
Committer: John Wagenleitner <jw...@apache.org>
Committed: Sun Apr 24 09:05:00 2016 -0700

----------------------------------------------------------------------
 .../groovy/json/internal/BaseJsonParser.java    |  5 +++-
 .../src/main/java/groovy/json/internal/Byt.java | 30 -------------------
 .../main/java/groovy/json/internal/CharBuf.java |  3 +-
 .../java/groovy/json/internal/Charsets.java     | 31 --------------------
 4 files changed, 6 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/2cdba2f0/subprojects/groovy-json/src/main/java/groovy/json/internal/BaseJsonParser.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-json/src/main/java/groovy/json/internal/BaseJsonParser.java b/subprojects/groovy-json/src/main/java/groovy/json/internal/BaseJsonParser.java
index 03e94de..699b1b8 100644
--- a/subprojects/groovy-json/src/main/java/groovy/json/internal/BaseJsonParser.java
+++ b/subprojects/groovy-json/src/main/java/groovy/json/internal/BaseJsonParser.java
@@ -24,6 +24,7 @@ import org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport;
 import org.codehaus.groovy.runtime.ResourceGroovyMethods;
 
 import java.io.*;
+import java.nio.charset.Charset;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
@@ -66,7 +67,9 @@ public abstract class BaseJsonParser implements JsonParser {
     protected static final boolean internKeys = Boolean.parseBoolean(System.getProperty("groovy.json.internKeys", "false"));
     protected static ConcurrentHashMap<String, String> internedKeysCache;
 
-    protected String charset = Charsets.UTF_8.name();
+    private static final Charset UTF_8 = Charset.forName("UTF-8");
+
+    protected String charset = UTF_8.name();
 
     private CharBuf fileInputBuf;
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/2cdba2f0/subprojects/groovy-json/src/main/java/groovy/json/internal/Byt.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-json/src/main/java/groovy/json/internal/Byt.java b/subprojects/groovy-json/src/main/java/groovy/json/internal/Byt.java
deleted file mode 100644
index 289b6e5..0000000
--- a/subprojects/groovy-json/src/main/java/groovy/json/internal/Byt.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package groovy.json.internal;
-
-/**
- * @author Richard Hightower
- */
-public class Byt {
-
-    public static void charTo(byte[] b, char val) {
-        b[1] = (byte) (val);
-        b[0] = (byte) (val >>> 8);
-    }
-}

http://git-wip-us.apache.org/repos/asf/groovy/blob/2cdba2f0/subprojects/groovy-json/src/main/java/groovy/json/internal/CharBuf.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-json/src/main/java/groovy/json/internal/CharBuf.java b/subprojects/groovy-json/src/main/java/groovy/json/internal/CharBuf.java
index 560a47c..feaa614 100644
--- a/subprojects/groovy-json/src/main/java/groovy/json/internal/CharBuf.java
+++ b/subprojects/groovy-json/src/main/java/groovy/json/internal/CharBuf.java
@@ -485,7 +485,8 @@ public class CharBuf extends Writer implements CharSequence {
                                 _location++;
                             }
                         } else {
-                            Byt.charTo(_charTo, c);
+                            _charTo[1] = (byte) (c);
+                            _charTo[0] = (byte) (c >>> 8);
 
                             for (int charByte : _charTo) {
                                 ByteScanner.encodeByteIntoTwoAsciiCharBytes(charByte, _encoded);

http://git-wip-us.apache.org/repos/asf/groovy/blob/2cdba2f0/subprojects/groovy-json/src/main/java/groovy/json/internal/Charsets.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-json/src/main/java/groovy/json/internal/Charsets.java b/subprojects/groovy-json/src/main/java/groovy/json/internal/Charsets.java
deleted file mode 100644
index f3bdbc2..0000000
--- a/subprojects/groovy-json/src/main/java/groovy/json/internal/Charsets.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- */
-package groovy.json.internal;
-
-import java.nio.charset.Charset;
-
-/**
- * @author Rick Hightower
- */
-public final class Charsets {
-
-    public static final Charset US_ASCII = Charset.forName("US-ASCII");
-    public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
-    public static final Charset UTF_8 = Charset.forName("UTF-8");
-}