From 06f3574e46e0623a45a93d36dbe7aa3d7455a995 Mon Sep 17 00:00:00 2001 From: nickhill Date: Fri, 18 May 2018 09:29:50 -0700 Subject: [PATCH] Don't calculate max direct memory twice in PlatformDependent Motivation: I'm not sure if trivial changes like this are interesting :-) But I noticed that the PlatformDependent.maxDirectMemory0() method is called twice unnecessarily during static initialization (on the default path at least). Modifications: Use constant MAX_DIRECT_MEMORY already set to the same value instead of calling maxDirectMemory0() again. Result: A surely imperceivable reduction in operations performed at startup. --- .../src/main/java/io/netty/util/internal/PlatformDependent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/io/netty/util/internal/PlatformDependent.java b/common/src/main/java/io/netty/util/internal/PlatformDependent.java index e6b082d859..d7a8a26218 100644 --- a/common/src/main/java/io/netty/util/internal/PlatformDependent.java +++ b/common/src/main/java/io/netty/util/internal/PlatformDependent.java @@ -158,7 +158,7 @@ public final class PlatformDependent { } else { USE_DIRECT_BUFFER_NO_CLEANER = true; if (maxDirectMemory < 0) { - maxDirectMemory = maxDirectMemory0(); + maxDirectMemory = MAX_DIRECT_MEMORY; if (maxDirectMemory <= 0) { DIRECT_MEMORY_COUNTER = null; } else {