myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject [myfaces-tobago] branch master updated: optimize String encoding (without RegExp)
Date Wed, 18 Apr 2018 09:14:16 GMT
This is an automated email from the ASF dual-hosted git repository.

lofwyr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/master by this push:
     new ab1939c  optimize String encoding (without RegExp)
ab1939c is described below

commit ab1939c6a5e84da9551f5bedbecbbfc539747a49
Author: Udo Schnurpfeil <lofwyr@apache.org>
AuthorDate: Wed Apr 18 11:14:04 2018 +0200

    optimize String encoding (without RegExp)
---
 .../org/apache/myfaces/tobago/internal/util/JsonUtils.java     | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/JsonUtils.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/JsonUtils.java
index 14a69e3..70f6e4f 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/JsonUtils.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/JsonUtils.java
@@ -98,7 +98,15 @@ public class JsonUtils {
     builder.append("\"");
     builder.append(name);
     builder.append("\":\"");
-    builder.append(value.replaceAll("\\\"", "\\\\\\\"")); // todo: optimize
+    int length = value.length();
+    for (int i = 0; i < length; i++) {
+      final char c = value.charAt(i);
+      if (c == '\"') {
+        builder.append("\\\"");
+      } else {
+        builder.append(c);
+      }
+    }
     builder.append("\",");
   }
 

-- 
To stop receiving notification emails like this one, please contact
lofwyr@apache.org.

Mime
View raw message