Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #44 from gatling/cleanup
Browse files Browse the repository at this point in the history
Minor performance improvements
  • Loading branch information
iconara authored Jun 4, 2019
2 parents a37f963 + 012495e commit d73cfaa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ public String unescape(String str) {
char c = str.charAt(slashIndex + 1);
char r = (c < unescapeMap.length) ? unescapeMap[c] : NO_REPLACEMENT;
if (r != NO_REPLACEMENT) {
unescaped.append(str.substring(offset, slashIndex));
unescaped.append(str, offset, slashIndex);
unescaped.append(r);
offset = slashIndex + 2;
} else if (unescapeUnicodeEscapes && c == 'u') {
String hexCode = str.substring(slashIndex + 2, slashIndex + 6);
String replacement = new String(Character.toChars(Integer.parseInt(hexCode, 16)));
unescaped.append(str.substring(offset, slashIndex));
unescaped.append(str, offset, slashIndex);
unescaped.append(replacement);
offset = slashIndex + 6;
}
slashIndex = str.indexOf('\\', slashIndex + 2);
}
unescaped.append(str.substring(offset, str.length()));
unescaped.append(str, offset, str.length());
return unescaped.toString();
} else {
return str;
Expand All @@ -74,14 +74,14 @@ public String escape(String str) {
char c = str.charAt(i);
char r = (c < escapeMap.length) ? escapeMap[c] : NO_REPLACEMENT;
if (r != NO_REPLACEMENT) {
escaped.append(str.substring(offset, i));
escaped.append(str, offset, i);
escaped.append('\\');
escaped.append(r);
offset = i + 1;
}
}
if (offset < str.length()) {
escaped.append(str.substring(offset, str.length()));
escaped.append(str, offset, str.length());
}
return escaped.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ public JsonElement createBoolean(boolean b) {

@Override
public JsonElement createObject(Map<JsonElement, JsonElement> obj) {
JsonElement object = new JsonObject();
JsonObject object = new JsonObject();
for (Map.Entry<JsonElement, JsonElement> entry : obj.entrySet()) {
((JsonObject) object).add(entry.getKey().getAsString(), entry.getValue());
object.add(entry.getKey().getAsString(), entry.getValue());
}
return object;
}
Expand Down

0 comments on commit d73cfaa

Please sign in to comment.