mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 04:09:54 +01:00
1718f61bf8
Doesn't compile yet. CraftBukkit Changes: 90d6905b Repackage NMS 69cf961d Repackage patches Spigot Changes: 79d53c28 Repackage NMS
85 lines
3.5 KiB
Diff
85 lines
3.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Tue, 5 Apr 2016 21:38:58 -0400
|
|
Subject: [PATCH] Optimize DataBits
|
|
|
|
Remove Debug checks as these are super hot and causing noticeable hits
|
|
|
|
Before: http://i.imgur.com/nQsMzAE.png
|
|
After: http://i.imgur.com/nJ46crB.png
|
|
|
|
Optimize redundant converting of static fields into an unsigned long each call by precomputing it in ctor
|
|
|
|
diff --git a/src/main/java/net/minecraft/util/DataBits.java b/src/main/java/net/minecraft/util/DataBits.java
|
|
index 0c0576c8730069fb5364d8383dec8ab7e698658d..c4f3b680512fb15cea01ad12d0a00c6e60bf34b7 100644
|
|
--- a/src/main/java/net/minecraft/util/DataBits.java
|
|
+++ b/src/main/java/net/minecraft/util/DataBits.java
|
|
@@ -13,8 +13,8 @@ public class DataBits {
|
|
private final long d;
|
|
private final int e;
|
|
private final int f;
|
|
- private final int g;
|
|
- private final int h;
|
|
+ private final int g;private final long g_unsigned; // Paper - referenced in b(int) with 2 Integer.toUnsignedLong calls
|
|
+ private final int h;private final long h_unsigned; // Paper
|
|
private final int i;
|
|
|
|
public DataBits(int i, int j) {
|
|
@@ -29,8 +29,8 @@ public class DataBits {
|
|
this.f = (char) (64 / i);
|
|
int k = 3 * (this.f - 1);
|
|
|
|
- this.g = DataBits.a[k + 0];
|
|
- this.h = DataBits.a[k + 1];
|
|
+ this.g = DataBits.a[k + 0]; this.g_unsigned = Integer.toUnsignedLong(this.g); // Paper
|
|
+ this.h = DataBits.a[k + 1]; this.h_unsigned = Integer.toUnsignedLong(this.h); // Paper
|
|
this.i = DataBits.a[k + 2];
|
|
int l = (j + this.f - 1) / this.f;
|
|
|
|
@@ -47,15 +47,15 @@ public class DataBits {
|
|
}
|
|
|
|
private int b(int i) {
|
|
- long j = Integer.toUnsignedLong(this.g);
|
|
- long k = Integer.toUnsignedLong(this.h);
|
|
+ //long j = Integer.toUnsignedLong(this.g); // Paper
|
|
+ //long k = Integer.toUnsignedLong(this.h); // Paper
|
|
|
|
- return (int) ((long) i * j + k >> 32 >> this.i);
|
|
+ return (int) ((long) i * this.g_unsigned + this.h_unsigned >> 32 >> this.i); // Paper
|
|
}
|
|
|
|
- public int a(int i, int j) {
|
|
- Validate.inclusiveBetween(0L, (long) (this.e - 1), (long) i);
|
|
- Validate.inclusiveBetween(0L, this.d, (long) j);
|
|
+ public final int a(int i, int j) { // Paper - make final for inline
|
|
+ //Validate.inclusiveBetween(0L, (long) (this.e - 1), (long) i); // Paper
|
|
+ //Validate.inclusiveBetween(0L, this.d, (long) j); // Paper
|
|
int k = this.b(i);
|
|
long l = this.b[k];
|
|
int i1 = (i - k * this.f) * this.c;
|
|
@@ -65,9 +65,9 @@ public class DataBits {
|
|
return j1;
|
|
}
|
|
|
|
- public void b(int i, int j) {
|
|
- Validate.inclusiveBetween(0L, (long) (this.e - 1), (long) i);
|
|
- Validate.inclusiveBetween(0L, this.d, (long) j);
|
|
+ public final void b(int i, int j) { // Paper - make final for inline
|
|
+ //Validate.inclusiveBetween(0L, (long) (this.e - 1), (long) i); // Paper
|
|
+ //Validate.inclusiveBetween(0L, this.d, (long) j); // Paper
|
|
int k = this.b(i);
|
|
long l = this.b[k];
|
|
int i1 = (i - k * this.f) * this.c;
|
|
@@ -75,8 +75,8 @@ public class DataBits {
|
|
this.b[k] = l & ~(this.d << i1) | ((long) j & this.d) << i1;
|
|
}
|
|
|
|
- public int a(int i) {
|
|
- Validate.inclusiveBetween(0L, (long) (this.e - 1), (long) i);
|
|
+ public final int a(int i) { // Paper - make final for inline
|
|
+ //Validate.inclusiveBetween(0L, (long) (this.e - 1), (long) i); // Paper
|
|
int j = this.b(i);
|
|
long k = this.b[j];
|
|
int l = (i - j * this.f) * this.c;
|