Use Arrays::fill instead of hand-written loop

This commit is contained in:
stsypanov
2019-03-14 16:28:08 +02:00
committed by Juergen Hoeller
parent 29f382b04e
commit e94af52510
2 changed files with 3 additions and 6 deletions

View File

@@ -49,9 +49,7 @@ public abstract class AbstractXhrTransport implements XhrTransport {
static {
byte[] bytes = new byte[2048];
for (int i = 0; i < bytes.length; i++) {
bytes[i] = 'h';
}
Arrays.fill(bytes, (byte) 'h');
PRELUDE = new String(bytes, SockJsFrame.CHARSET);
}

View File

@@ -17,6 +17,7 @@
package org.springframework.web.socket.sockjs.transport.handler;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Map;
import org.springframework.http.MediaType;
@@ -41,9 +42,7 @@ public class XhrStreamingTransportHandler extends AbstractHttpSendingTransportHa
private static final byte[] PRELUDE = new byte[2049];
static {
for (int i = 0; i < 2048; i++) {
PRELUDE[i] = 'h';
}
Arrays.fill(PRELUDE, (byte) 'h');
PRELUDE[2048] = '\n';
}