Skip to content

Commit a32c665

Browse files
Optimize conditionals in ParallelFormatBenchmark by replacing modulus checks with bitwise operations
1 parent 9681c6e commit a32c665

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

benchmarks/src/jmh/kotlin/ParallelFormatBenchmark.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ open class ParallelFormatBenchmark {
5252
primaryFormat = { year(); char('-'); monthNumber(); char('-'); day() }
5353
)
5454

55-
if (index % 2 == 0) {
55+
if (index and 1 == 0) {
5656
alternativeParsing(
5757
{
5858
alternativeParsing(
@@ -74,7 +74,7 @@ open class ParallelFormatBenchmark {
7474
char('|')
7575
}
7676

77-
if (index < 8) {
77+
if (index and 2 == 0) {
7878
alternativeParsing(
7979
{ char('Z') },
8080
{ char('+'); hour(); char(':'); minute() },

0 commit comments

Comments
 (0)