mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Remove redundant boxing
See gh-39259
This commit is contained in:
parent
e40f49d173
commit
74a7fbea9d
@ -136,12 +136,12 @@ public class Snake {
|
||||
public String getLocationsJson() {
|
||||
synchronized (this.monitor) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(String.format("{x: %d, y: %d}", Integer.valueOf(this.head.x), Integer.valueOf(this.head.y)));
|
||||
sb.append(String.format("{x: %d, y: %d}", this.head.x, this.head.y));
|
||||
for (Location location : this.tail) {
|
||||
sb.append(',');
|
||||
sb.append(String.format("{x: %d, y: %d}", Integer.valueOf(location.x), Integer.valueOf(location.y)));
|
||||
sb.append(String.format("{x: %d, y: %d}", location.x, location.y));
|
||||
}
|
||||
return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id), sb);
|
||||
return String.format("{'id':%d,'body':[%s]}", this.id, sb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public final class SnakeTimer {
|
||||
if (snakes.isEmpty()) {
|
||||
startTimer();
|
||||
}
|
||||
snakes.put(Integer.valueOf(snake.getId()), snake);
|
||||
snakes.put(snake.getId(), snake);
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ public final class SnakeTimer {
|
||||
|
||||
public static void removeSnake(Snake snake) {
|
||||
synchronized (MONITOR) {
|
||||
snakes.remove(Integer.valueOf(snake.getId()));
|
||||
snakes.remove(snake.getId());
|
||||
if (snakes.isEmpty()) {
|
||||
stopTimer();
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Iterator<Snake> iterator = SnakeTimer.getSnakes().iterator(); iterator.hasNext();) {
|
||||
Snake snake = iterator.next();
|
||||
sb.append(String.format("{id: %d, color: '%s'}", Integer.valueOf(snake.getId()), snake.getHexColor()));
|
||||
sb.append(String.format("{id: %d, color: '%s'}", snake.getId(), snake.getHexColor()));
|
||||
if (iterator.hasNext()) {
|
||||
sb.append(',');
|
||||
}
|
||||
@ -97,7 +97,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
|
||||
@Override
|
||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
|
||||
SnakeTimer.removeSnake(this.snake);
|
||||
SnakeTimer.broadcast(String.format("{'type': 'leave', 'id': %d}", Integer.valueOf(this.id)));
|
||||
SnakeTimer.broadcast(String.format("{'type': 'leave', 'id': %d}", this.id));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -136,12 +136,12 @@ public class Snake {
|
||||
public String getLocationsJson() {
|
||||
synchronized (this.monitor) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(String.format("{x: %d, y: %d}", Integer.valueOf(this.head.x), Integer.valueOf(this.head.y)));
|
||||
sb.append(String.format("{x: %d, y: %d}", this.head.x, this.head.y));
|
||||
for (Location location : this.tail) {
|
||||
sb.append(',');
|
||||
sb.append(String.format("{x: %d, y: %d}", Integer.valueOf(location.x), Integer.valueOf(location.y)));
|
||||
sb.append(String.format("{x: %d, y: %d}", location.x, location.y));
|
||||
}
|
||||
return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id), sb);
|
||||
return String.format("{'id':%d,'body':[%s]}", this.id, sb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public final class SnakeTimer {
|
||||
if (snakes.isEmpty()) {
|
||||
startTimer();
|
||||
}
|
||||
snakes.put(Integer.valueOf(snake.getId()), snake);
|
||||
snakes.put(snake.getId(), snake);
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ public final class SnakeTimer {
|
||||
|
||||
public static void removeSnake(Snake snake) {
|
||||
synchronized (MONITOR) {
|
||||
snakes.remove(Integer.valueOf(snake.getId()));
|
||||
snakes.remove(snake.getId());
|
||||
if (snakes.isEmpty()) {
|
||||
stopTimer();
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Iterator<Snake> iterator = SnakeTimer.getSnakes().iterator(); iterator.hasNext();) {
|
||||
Snake snake = iterator.next();
|
||||
sb.append(String.format("{id: %d, color: '%s'}", Integer.valueOf(snake.getId()), snake.getHexColor()));
|
||||
sb.append(String.format("{id: %d, color: '%s'}", snake.getId(), snake.getHexColor()));
|
||||
if (iterator.hasNext()) {
|
||||
sb.append(',');
|
||||
}
|
||||
@ -97,7 +97,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
|
||||
@Override
|
||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
|
||||
SnakeTimer.removeSnake(this.snake);
|
||||
SnakeTimer.broadcast(String.format("{'type': 'leave', 'id': %d}", Integer.valueOf(this.id)));
|
||||
SnakeTimer.broadcast(String.format("{'type': 'leave', 'id': %d}", this.id));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -136,12 +136,12 @@ public class Snake {
|
||||
public String getLocationsJson() {
|
||||
synchronized (this.monitor) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(String.format("{x: %d, y: %d}", Integer.valueOf(this.head.x), Integer.valueOf(this.head.y)));
|
||||
sb.append(String.format("{x: %d, y: %d}", this.head.x, this.head.y));
|
||||
for (Location location : this.tail) {
|
||||
sb.append(',');
|
||||
sb.append(String.format("{x: %d, y: %d}", Integer.valueOf(location.x), Integer.valueOf(location.y)));
|
||||
sb.append(String.format("{x: %d, y: %d}", location.x, location.y));
|
||||
}
|
||||
return String.format("{'id':%d,'body':[%s]}", Integer.valueOf(this.id), sb);
|
||||
return String.format("{'id':%d,'body':[%s]}", this.id, sb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public final class SnakeTimer {
|
||||
if (snakes.isEmpty()) {
|
||||
startTimer();
|
||||
}
|
||||
snakes.put(Integer.valueOf(snake.getId()), snake);
|
||||
snakes.put(snake.getId(), snake);
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ public final class SnakeTimer {
|
||||
|
||||
public static void removeSnake(Snake snake) {
|
||||
synchronized (MONITOR) {
|
||||
snakes.remove(Integer.valueOf(snake.getId()));
|
||||
snakes.remove(snake.getId());
|
||||
if (snakes.isEmpty()) {
|
||||
stopTimer();
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Iterator<Snake> iterator = SnakeTimer.getSnakes().iterator(); iterator.hasNext();) {
|
||||
Snake snake = iterator.next();
|
||||
sb.append(String.format("{id: %d, color: '%s'}", Integer.valueOf(snake.getId()), snake.getHexColor()));
|
||||
sb.append(String.format("{id: %d, color: '%s'}", snake.getId(), snake.getHexColor()));
|
||||
if (iterator.hasNext()) {
|
||||
sb.append(',');
|
||||
}
|
||||
@ -97,7 +97,7 @@ public class SnakeWebSocketHandler extends TextWebSocketHandler {
|
||||
@Override
|
||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
|
||||
SnakeTimer.removeSnake(this.snake);
|
||||
SnakeTimer.broadcast(String.format("{'type': 'leave', 'id': %d}", Integer.valueOf(this.id)));
|
||||
SnakeTimer.broadcast(String.format("{'type': 'leave', 'id': %d}", this.id));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user