diff --git a/CHANGES.txt b/CHANGES.txt index 9795f6fe723..c951814f53c 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -78,6 +78,7 @@ New Features Changes in runtime behavior Optimizations + 1. SOLR-276: improve JSON writer speed. (yonik) Bug Fixes 1. Make TextField respect sortMissingFirst and sortMissingLast fields. diff --git a/src/java/org/apache/solr/request/JSONResponseWriter.java b/src/java/org/apache/solr/request/JSONResponseWriter.java index ad52111dd9d..080b9b3ceea 100644 --- a/src/java/org/apache/solr/request/JSONResponseWriter.java +++ b/src/java/org/apache/solr/request/JSONResponseWriter.java @@ -458,7 +458,6 @@ class JSONWriter extends TextResponseWriter { public void writeStr(String name, String val, boolean needsEscaping) throws IOException { - writer.write('"'); // it might be more efficient to use a stringbuilder or write substrings // if writing chars to the stream is slow. if (needsEscaping) { @@ -471,33 +470,40 @@ class JSONWriter extends TextResponseWriter { characters (U+0000 through U+001F). */ + StringBuilder sb = new StringBuilder(val.length()+8); + sb.append('"'); + for (int i=0; i