Skip to content

Commit 18f6cba

Browse files
committed
Optimizations
1 parent 37f3f85 commit 18f6cba

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# FastBoard
22
[![Java CI](https://github.com/MrMicky-FR/FastBoard/actions/workflows/build.yml/badge.svg)](https://github.com/MrMicky-FR/FastBoard/actions/workflows/build.yml)
3+
[![Language grade](https://img.shields.io/lgtm/grade/java/github/MrMicky-FR/FastBoard.svg?logo=lgtm&logoWidth=18&label=code%20quality)](https://lgtm.com/projects/g/MrMicky-FR/FastBoard/context:java)
34
[![Maven Central](https://img.shields.io/maven-central/v/fr.mrmicky/fastboard.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22fr.mrmicky%22%20AND%20a:%22fastboard%22)
45
[![Discord](https://img.shields.io/discord/390919659874156560.svg?colorB=5865f2&label=Discord&logo=discord&logoColor=white)](https://discord.gg/q9UwaBT)
56

src/main/java/fr/mrmicky/fastboard/FastBoard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ private void checkLineNumber(int line, boolean checkInRange, boolean checkMax) {
437437
}
438438

439439
if (checkMax && line >= COLOR_CODES.length - 1) {
440-
throw new IllegalArgumentException("Line number is too high: " + this.lines.size());
440+
throw new IllegalArgumentException("Line number is too high: " + line);
441441
}
442442
}
443443

src/main/java/fr/mrmicky/fastboard/FastReflection.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.lang.invoke.MethodHandles;
3030
import java.lang.invoke.MethodType;
3131
import java.lang.reflect.Field;
32-
import java.lang.reflect.Method;
3332
import java.util.Optional;
3433
import java.util.function.Predicate;
3534

@@ -139,7 +138,8 @@ public static PacketConstructor findPacketConstructor(Class<?> packetClass, Meth
139138
}
140139
}
141140

142-
Method allocateMethod = theUnsafe.getClass().getMethod("allocateInstance", Class.class);
141+
MethodType allocateMethodType = MethodType.methodType(Object.class, Class.class);
142+
MethodHandle allocateMethod = lookup.findVirtual(theUnsafe.getClass(), "allocateInstance", allocateMethodType);
143143
return () -> allocateMethod.invoke(theUnsafe, packetClass);
144144
}
145145

0 commit comments

Comments
 (0)