mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-12-26 18:37:59 +01:00
ActionFrequency.update: reorder safety checks slightly.
Gains a little bit of consistency for negative time differences. Also might be faster for the case of seldom shifting, though most likely by an insignificant amount.
This commit is contained in:
parent
363cda50e8
commit
f0e9a844fc
@ -50,16 +50,16 @@ public class ActionFrequency {
|
||||
*/
|
||||
public final void update(final long now) {
|
||||
final long diff = now - time;
|
||||
final int shift = (int) ((float) diff / (float) durBucket);
|
||||
if (shift == 0){
|
||||
// No update.
|
||||
if (diff < durBucket){
|
||||
// No update (first bucket).
|
||||
return;
|
||||
}
|
||||
else if (shift >= buckets.length || shift < 0){
|
||||
else if (diff >= durBucket * buckets.length || diff < 0){
|
||||
// Clear (beyond range).
|
||||
clear(now);
|
||||
return;
|
||||
}
|
||||
final int shift = (int) ((float) diff / (float) durBucket);
|
||||
// Update buckets.
|
||||
for (int i = 0; i < buckets.length - shift; i++){
|
||||
buckets[buckets.length - (i + 1)] = buckets[buckets.length - (i + 1 + shift)];
|
||||
|
Loading…
Reference in New Issue
Block a user