Use temporary StringBuilder for string concatenation in loop
This commit is contained in:
parent
b4d8868e9d
commit
dde04c5a01
|
@ -1138,17 +1138,19 @@ public abstract class NanoHTTPD {
|
||||||
|
|
||||||
String value = "";
|
String value = "";
|
||||||
if (item.get("content-type") == null) {
|
if (item.get("content-type") == null) {
|
||||||
|
StringBuilder tmp = new StringBuilder();
|
||||||
while (mpline != null && !mpline.contains(boundary)) {
|
while (mpline != null && !mpline.contains(boundary)) {
|
||||||
mpline = in.readLine();
|
mpline = in.readLine();
|
||||||
if (mpline != null) {
|
if (mpline != null) {
|
||||||
int d = mpline.indexOf(boundary);
|
int d = mpline.indexOf(boundary);
|
||||||
if (d == -1) {
|
if (d == -1) {
|
||||||
value += mpline;
|
tmp.append(mpline);
|
||||||
} else {
|
} else {
|
||||||
value += mpline.substring(0, d - 2);
|
tmp.append(mpline.substring(0, d - 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
value = tmp.toString();
|
||||||
} else {
|
} else {
|
||||||
if (boundarycount > bpositions.length) {
|
if (boundarycount > bpositions.length) {
|
||||||
throw new ResponseException(Response.Status.INTERNAL_ERROR, "Error processing request");
|
throw new ResponseException(Response.Status.INTERNAL_ERROR, "Error processing request");
|
||||||
|
@ -1156,8 +1158,7 @@ public abstract class NanoHTTPD {
|
||||||
int offset = stripMultipartHeaders(fbuf, bpositions[boundarycount - 2]);
|
int offset = stripMultipartHeaders(fbuf, bpositions[boundarycount - 2]);
|
||||||
String path = saveTmpFile(fbuf, offset, bpositions[boundarycount - 1] - offset - 4);
|
String path = saveTmpFile(fbuf, offset, bpositions[boundarycount - 1] - offset - 4);
|
||||||
files.put(pname, path);
|
files.put(pname, path);
|
||||||
value = disposition.get("filename");
|
value = disposition.get("filename").substring(1, value.length() - 1);
|
||||||
value = value.substring(1, value.length() - 1);
|
|
||||||
do {
|
do {
|
||||||
mpline = in.readLine();
|
mpline = in.readLine();
|
||||||
} while (mpline != null && !mpline.contains(boundary));
|
} while (mpline != null && !mpline.contains(boundary));
|
||||||
|
|
Loading…
Reference in New Issue