Cached original string length in JSONValue#escape to avoid repeated calls to String#length.

This commit is contained in:
jon.chambers@gmail.com
2013-08-10 03:34:33 +00:00
parent 2d0898ad12
commit 9a32bb5017

View File

@@ -321,7 +321,8 @@ public class JSONValue {
* @param sb * @param sb
*/ */
static void escape(String s, StringBuffer sb) { static void escape(String s, StringBuffer sb) {
for(int i=0;i<s.length();i++){ final int len = s.length();
for(int i=0;i<len;i++){
char ch=s.charAt(i); char ch=s.charAt(i);
switch(ch){ switch(ch){
case '"': case '"':