Skip to content

Commit 102d1cb

Browse files
committed
Optimization
1 parent 04043d8 commit 102d1cb

File tree

1 file changed

+4
-1
lines changed
  • frameworks/Java/inverno/src/main/java/com/techempower/inverno/benchmark/internal

1 file changed

+4
-1
lines changed

frameworks/Java/inverno/src/main/java/com/techempower/inverno/benchmark/internal/Handler.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.time.ZonedDateTime;
44
import java.time.format.DateTimeFormatter;
55
import java.util.Collections;
6+
import java.util.concurrent.CompletableFuture;
67
import java.util.concurrent.ThreadLocalRandom;
78
import java.util.concurrent.TimeUnit;
89
import java.util.function.Supplier;
@@ -280,6 +281,8 @@ public void handle_updates(Exchange exchange) throws HttpException {
280281
private static final String DB_SELECT_FORTUNE = "SELECT id, message from FORTUNE";
281282
private static final CharSequence MEDIA_TEXT_HTML_UTF8 = AsciiString.cached("text/html; charset=utf-8");
282283

284+
private static final FortunesTemplate.Renderer<CompletableFuture<ByteBuf>> FORTUNES_RENDERER = FortunesTemplate.bytebuf(() -> Unpooled.unreleasableBuffer(Unpooled.buffer()));
285+
283286
public void handle_fortunes(Exchange exchange) throws HttpException {
284287
exchange.response()
285288
.headers(h -> h
@@ -296,7 +299,7 @@ public void handle_fortunes(Exchange exchange) throws HttpException {
296299
.flatMap(fortunes -> {
297300
fortunes.add(new Fortune(0, "Additional fortune added at request time."));
298301
Collections.sort(fortunes);
299-
return Mono.fromFuture(() -> FortunesTemplate.bytebuf(() -> Unpooled.unreleasableBuffer(Unpooled.buffer())).render(fortunes));
302+
return Mono.fromFuture(() -> FORTUNES_RENDERER.render(fortunes));
300303
})
301304
);
302305
}

0 commit comments

Comments
 (0)