Skip to content

Commit c7a57ab

Browse files
author
Artem Golovko
committed
use primitive type for better performance
1 parent b92d8e7 commit c7a57ab

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/main/kotlin/a0/A0FrequencyModel.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import commons.NUMBER_OF_CHARS
44

55
internal class A0FrequencyModel {
66

7-
private val charToIndex = Array<Int>(NUMBER_OF_CHARS) { 0 }
7+
private val charToIndex = IntArray(NUMBER_OF_CHARS) { 0 }
88

9-
private val indexToChar = Array<Int>(NUMBER_OF_SYMBOLS + 1) { 0 }
9+
private val indexToChar = IntArray(NUMBER_OF_SYMBOLS + 1) { 0 }
1010

11-
private val frequencies = Array<Int>(NUMBER_OF_SYMBOLS + 1) { 0 }
11+
private val frequencies = IntArray(NUMBER_OF_SYMBOLS + 1) { 0 }
1212

13-
private val cumulative = Array<Int>(NUMBER_OF_SYMBOLS + 1) { 0 }
13+
private val cumulative = IntArray(NUMBER_OF_SYMBOLS + 1) { 0 }
1414

1515
init {
1616
(0 until NUMBER_OF_CHARS).forEach {

src/main/kotlin/bwt/BWTDecoder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ private class BWTDecoderWriter(
2020

2121
private val buffer = ByteArray(BLOCK_SIZE + 1 + 2 * Int.SIZE_BYTES)
2222

23-
private val BWTReverseVector = Array<Int>(BLOCK_SIZE + 1) { 0 }
23+
private val BWTReverseVector = IntArray(BLOCK_SIZE + 1) { 0 }
2424

25-
private val count = Array<Int>(NUMBER_OF_CHARS + 1) { 0 }
25+
private val count = IntArray(NUMBER_OF_CHARS + 1) { 0 }
2626

2727
private var bufferLength = -1
2828

src/main/kotlin/mtf/MTFCoder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ private class MTFCoderWriter(
1818
private val output: OutputStream
1919
) : CoderWriter {
2020

21-
private val indexToByte = Array<Int>(NUMBER_OF_CHARS) { it }
21+
private val indexToByte = IntArray(NUMBER_OF_CHARS) { it }
2222

2323
override fun writeEncoded() {
2424
input.forEachByte { byte ->

src/main/kotlin/mtf/MTFDecoder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ private class MTFDecoderWriter(
1818
private val output: OutputStream
1919
) : DecoderWriter {
2020

21-
private val indexToByte = Array<Int>(NUMBER_OF_CHARS) { it }
21+
private val indexToByte = IntArray(NUMBER_OF_CHARS) { it }
2222

2323
override fun writeDecoded() {
2424
input.forEachByte { index ->

0 commit comments

Comments
 (0)