Skip to content

Commit 2b090f0

Browse files
committed
Code tidy after code inspections
1 parent 90d91a1 commit 2b090f0

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

affinity/src/main/java/net/openhft/affinity/AffinityStrategies.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ public boolean matches(int cpuId, int cpuId2) {
7575
CpuLayout cpuLayout = AffinityLock.cpuLayout();
7676
return cpuLayout.socketId(cpuId) != cpuLayout.socketId(cpuId2);
7777
}
78-
};
78+
}
7979

8080
}

affinity/src/main/java/net/openhft/affinity/LockInventory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class LockInventory {
3434
* The locks belonging to physical cores. Since a physical core can host multiple logical cores
3535
* the relationship is one to many.
3636
*/
37-
private final NavigableMap<Integer, AffinityLock[]> physicalCoreLocks = new TreeMap<Integer, AffinityLock[]>();
37+
private final NavigableMap<Integer, AffinityLock[]> physicalCoreLocks = new TreeMap<>();
3838
private CpuLayout cpuLayout;
3939
/**
4040
* The lock belonging to each logical core. 1-to-1 relationship

affinity/src/main/java/net/openhft/affinity/impl/LinuxHelper.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import java.util.Arrays;
2525
import java.util.BitSet;
26+
import java.util.Collections;
2627
import java.util.List;
2728

2829
public class LinuxHelper {
@@ -281,7 +282,7 @@ public static class cpu_set_t extends Structure {
281282
static final int __CPU_SETSIZE = 1024;
282283
static final int __NCPUBITS = 8 * NativeLong.SIZE;
283284
static final int SIZE_OF_CPU_SET_T = (__CPU_SETSIZE / __NCPUBITS) * NativeLong.SIZE;
284-
static List<String> FIELD_ORDER = Arrays.asList("__bits");
285+
static List<String> FIELD_ORDER = Collections.singletonList("__bits");
285286
public NativeLong[] __bits = new NativeLong[__CPU_SETSIZE / __NCPUBITS];
286287

287288
public cpu_set_t() {
@@ -293,7 +294,7 @@ public cpu_set_t() {
293294
@SuppressWarnings({"UnusedDeclaration"})
294295
public static void __CPU_ZERO(cpu_set_t cpuset) {
295296
for (NativeLong bits : cpuset.__bits) {
296-
bits.setValue(0l);
297+
bits.setValue(0L);
297298
}
298299
}
299300

@@ -302,7 +303,7 @@ public static int __CPUELT(int cpu) {
302303
}
303304

304305
public static long __CPUMASK(int cpu) {
305-
return 1l << (cpu % __NCPUBITS);
306+
return 1L << (cpu % __NCPUBITS);
306307
}
307308

308309
@SuppressWarnings({"UnusedDeclaration"})

affinity/src/main/java/net/openhft/affinity/impl/PosixJNAAffinity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public enum PosixJNAAffinity implements IAffinity {
7070
LOADED = loaded;
7171
}
7272

73-
private final ThreadLocal<Integer> THREAD_ID = new ThreadLocal<Integer>();
73+
private final ThreadLocal<Integer> THREAD_ID = new ThreadLocal<>();
7474

7575
public static boolean is64Bit() {
7676
return IS64BIT;

affinity/src/main/java/net/openhft/affinity/impl/Utilities.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public static String toHexString(final BitSet set) {
3939
ByteArrayOutputStream out = new ByteArrayOutputStream();
4040
PrintWriter writer = new PrintWriter(out);
4141
final long[] longs = set.toLongArray();
42-
for (int i = 0; i < longs.length; i++) {
43-
writer.write(Long.toHexString(longs[i]));
42+
for (long aLong : longs) {
43+
writer.write(Long.toHexString(aLong));
4444
}
4545
writer.flush();
4646

@@ -51,8 +51,8 @@ public static String toBinaryString(BitSet set) {
5151
ByteArrayOutputStream out = new ByteArrayOutputStream();
5252
PrintWriter writer = new PrintWriter(out);
5353
final long[] longs = set.toLongArray();
54-
for (int i = 0; i < longs.length; i++) {
55-
writer.write(Long.toBinaryString(longs[i]));
54+
for (long aLong : longs) {
55+
writer.write(Long.toBinaryString(aLong));
5656
}
5757
writer.flush();
5858

affinity/src/main/java/net/openhft/affinity/impl/VanillaCpuLayout.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public class VanillaCpuLayout implements CpuLayout {
4040

4141
VanillaCpuLayout(@NotNull List<CpuInfo> cpuDetails) {
4242
this.cpuDetails = cpuDetails;
43-
SortedSet<Integer> sockets = new TreeSet<Integer>(),
44-
cores = new TreeSet<Integer>(),
45-
threads = new TreeSet<Integer>();
43+
SortedSet<Integer> sockets = new TreeSet<>(),
44+
cores = new TreeSet<>(),
45+
threads = new TreeSet<>();
4646
for (CpuInfo cpuDetail : cpuDetails) {
4747
sockets.add(cpuDetail.socketId);
4848
cores.add((cpuDetail.socketId << 16) + cpuDetail.coreId);
@@ -78,7 +78,7 @@ public static VanillaCpuLayout fromProperties(InputStream is) throws IOException
7878

7979
@NotNull
8080
public static VanillaCpuLayout fromProperties(@NotNull Properties prop) {
81-
List<CpuInfo> cpuDetails = new ArrayList<CpuInfo>();
81+
List<CpuInfo> cpuDetails = new ArrayList<>();
8282
for (int i = 0; i < MAX_CPUS_SUPPORTED; i++) {
8383
String line = prop.getProperty("" + i);
8484
if (line == null) break;
@@ -115,9 +115,9 @@ private static InputStream openFile(String filename) throws FileNotFoundExceptio
115115
public static VanillaCpuLayout fromCpuInfo(InputStream is) throws IOException {
116116
BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
117117
String line;
118-
List<CpuInfo> cpuDetails = new ArrayList<CpuInfo>();
118+
List<CpuInfo> cpuDetails = new ArrayList<>();
119119
CpuInfo details = new CpuInfo();
120-
Map<String, Integer> threadCount = new LinkedHashMap<String, Integer>();
120+
Map<String, Integer> threadCount = new LinkedHashMap<>();
121121

122122
while ((line = br.readLine()) != null) {
123123
if (line.trim().isEmpty()) {

0 commit comments

Comments
 (0)