mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Java optimization and formatting fixes (#4857)
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
package edu.wpi.first.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/** This is a simple circular buffer so we don't need to "bucket brigade" copy old values. */
|
||||
public class CircularBuffer {
|
||||
private double[] m_data;
|
||||
@@ -21,9 +23,7 @@ public class CircularBuffer {
|
||||
*/
|
||||
public CircularBuffer(int size) {
|
||||
m_data = new double[size];
|
||||
for (int i = 0; i < m_data.length; i++) {
|
||||
m_data[i] = 0.0;
|
||||
}
|
||||
Arrays.fill(m_data, 0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,9 +150,7 @@ public class CircularBuffer {
|
||||
|
||||
/** Sets internal buffer contents to zero. */
|
||||
public void clear() {
|
||||
for (int i = 0; i < m_data.length; i++) {
|
||||
m_data[i] = 0.0;
|
||||
}
|
||||
Arrays.fill(m_data, 0.0);
|
||||
m_front = 0;
|
||||
m_length = 0;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class EventVector {
|
||||
public void remove(int handle) {
|
||||
m_lock.lock();
|
||||
try {
|
||||
m_events.removeIf(x -> x.intValue() == handle);
|
||||
m_events.removeIf(x -> x == handle);
|
||||
} finally {
|
||||
m_lock.unlock();
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public final class RuntimeLoader<T> {
|
||||
if (hashIs == null) {
|
||||
throw new IOException(getLoadErrorMessage(ule));
|
||||
}
|
||||
try (Scanner scanner = new Scanner(hashIs, StandardCharsets.UTF_8.name())) {
|
||||
try (Scanner scanner = new Scanner(hashIs, StandardCharsets.UTF_8)) {
|
||||
String hash = scanner.nextLine();
|
||||
File jniLibrary = new File(m_extractionRoot, resName + "." + hash);
|
||||
try {
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.io.RandomAccessFile;
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.MappedByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.NoSuchElementException;
|
||||
@@ -36,8 +35,7 @@ public class DataLogReader implements Iterable<DataLogRecord> {
|
||||
public DataLogReader(String filename) throws IOException {
|
||||
RandomAccessFile f = new RandomAccessFile(filename, "r");
|
||||
FileChannel channel = f.getChannel();
|
||||
MappedByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
|
||||
m_buf = buf;
|
||||
m_buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
|
||||
m_buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
channel.close();
|
||||
f.close();
|
||||
|
||||
Reference in New Issue
Block a user