Skip to content

Commit 96edbb3

Browse files
U117293U117293
U117293
authored and
U117293
committed
feat: improved documentation for #385
1 parent ae16bae commit 96edbb3

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

java/src/main/java/io/cucumber/gherkin/Locations.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ class Locations {
2020
}
2121

2222
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
2336
if (i>=longs.length) return (long) i;
2437
return longs[i];
2538
}

0 commit comments

Comments
 (0)