Skip to content

Commit

Permalink
Use the default charset instead of looking up the charset each time. …
Browse files Browse the repository at this point in the history
…It should only contain 8bit ascii chars anyway.
  • Loading branch information
gnodet committed Apr 25, 2017
1 parent 8425e63 commit 7c9e5ba
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Iterator;

Expand Down Expand Up @@ -107,7 +108,7 @@ public void write(int data) throws IOException {
case LOOKING_FOR_INT_ARG_END:
buffer[pos++] = (byte) data;
if (!('0' <= data && data <= '9')) {
String strValue = new String(buffer, startOfValue, (pos - 1) - startOfValue, "UTF-8");
String strValue = new String(buffer, startOfValue, (pos - 1) - startOfValue, Charset.defaultCharset());
Integer value = Integer.parseInt(strValue);
options.add(value);
if (data == ';') {
Expand All @@ -121,7 +122,7 @@ public void write(int data) throws IOException {
case LOOKING_FOR_STR_ARG_END:
buffer[pos++] = (byte) data;
if ('"' != data) {
String value = new String(buffer, startOfValue, (pos - 1) - startOfValue, "UTF-8");
String value = new String(buffer, startOfValue, (pos - 1) - startOfValue, Charset.defaultCharset());
options.add(value);
if (data == ';') {
state = LOOKING_FOR_NEXT_ARG;
Expand All @@ -144,7 +145,7 @@ public void write(int data) throws IOException {
case LOOKING_FOR_OSC_COMMAND_END:
buffer[pos++] = (byte) data;
if (';' == data) {
String strValue = new String(buffer, startOfValue, (pos - 1) - startOfValue, "UTF-8");
String strValue = new String(buffer, startOfValue, (pos - 1) - startOfValue, Charset.defaultCharset());
Integer value = Integer.parseInt(strValue);
options.add(value);
startOfValue = pos;
Expand All @@ -160,7 +161,7 @@ public void write(int data) throws IOException {
case LOOKING_FOR_OSC_PARAM:
buffer[pos++] = (byte) data;
if (BEL == data) {
String value = new String(buffer, startOfValue, (pos - 1) - startOfValue, "UTF-8");
String value = new String(buffer, startOfValue, (pos - 1) - startOfValue, Charset.defaultCharset());
options.add(value);
reset(processOperatingSystemCommand(options));
} else if (FIRST_ESC_CHAR == data) {
Expand All @@ -173,7 +174,7 @@ public void write(int data) throws IOException {
case LOOKING_FOR_ST:
buffer[pos++] = (byte) data;
if (SECOND_ST_CHAR == data) {
String value = new String(buffer, startOfValue, (pos - 2) - startOfValue, "UTF-8");
String value = new String(buffer, startOfValue, (pos - 2) - startOfValue, Charset.defaultCharset());
options.add(value);
reset(processOperatingSystemCommand(options));
} else {
Expand Down

0 comments on commit 7c9e5ba

Please # to comment.