Skip to content

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jasontedor committed Jan 18, 2019
1 parent 8ef7ff2 commit 17646cf
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,16 +364,16 @@ static String escapeBackslashesAndQuotes(final String s) {
* We want a fast path check to avoid creating the string builder and copying characters if needed. So we walk the string looking
* for either of the characters that we need to escape. If we find a character that needs escaping, we start over and
*/
boolean encodingNeeded = false;
boolean escapingNeeded = false;
for (int i = 0; i < s.length(); i++) {
final char c = s.charAt(i);
if (c == '\\' || c == '"') {
encodingNeeded = true;
escapingNeeded = true;
break;
}
}

if (encodingNeeded) {
if (escapingNeeded) {
final StringBuilder sb = new StringBuilder();
for (final char c : s.toCharArray()) {
if (c == '\\' || c == '"') {
Expand Down Expand Up @@ -409,7 +409,7 @@ static String escapeBackslashesAndQuotes(final String s) {
for (int i = 0x80; i <= 0xFF; i++) {
doesNotNeedEncoding.set(i);
}
assert doesNotNeedEncoding.get('%') == false;
assert doesNotNeedEncoding.get('%') == false : doesNotNeedEncoding;
}

private static final Charset UTF_8 = Charset.forName("UTF-8");
Expand Down

0 comments on commit 17646cf

Please sign in to comment.