We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ae16bae commit 96edbb3Copy full SHA for 96edbb3
java/src/main/java/io/cucumber/gherkin/Locations.java
@@ -20,6 +20,19 @@ class Locations {
20
}
21
22
static Long getLong(int i) {
23
+ // JMH benchmark shows that this implementation is the
24
+ // fastest when i<4096 (and about 20% slower than
25
+ // Long.valueOf() when i>=4096).
26
+ //
27
+ // Tested variants:
28
+ // - static preinitialized cache of 127 elements
29
+ // (`Long.valueOf`)
30
+ // - static preinitialized cache of 4096 elements
31
+ // (the current implemented version)
32
+ // - dynamic preinitialized cache with 256 / 512 /
33
+ // 1024/2048/4096 initial size
34
+ // - dynamic lazy initialized cache with 256
35
+ // initialized size
36
if (i>=longs.length) return (long) i;
37
return longs[i];
38
0 commit comments