@@ -97,9 +97,8 @@ object Nbt {
9797 return @checkTimeout TagList (tagId, emptyList())
9898 }
9999
100- val list = ArrayList <NbtTag >(length)
101- for (i in 0 until length) {
102- list.add(this .readTag(tagId, start, timeout))
100+ val list = List (length) {
101+ this .readTag(tagId, start, timeout)
103102 }
104103 return @checkTimeout TagList (tagId, list)
105104 }
@@ -117,10 +116,8 @@ object Nbt {
117116 private fun DataInputStream.readIntArrayTag (start : Long , timeout : Long ) = checkTimeout(start, timeout) {
118117 val length = this .readInt()
119118
120- val ints = IntArray (length)
121-
122- for (i in 0 until length) {
123- ints[i] = this .readInt()
119+ val ints = IntArray (length) {
120+ this .readInt()
124121 }
125122
126123 return @checkTimeout TagIntArray (ints)
@@ -129,9 +126,8 @@ object Nbt {
129126 private fun DataInputStream.readLongArrayTag (start : Long , timeout : Long ) = checkTimeout(start, timeout) {
130127 val length = this .readInt()
131128
132- val longs = LongArray (length)
133- for (i in 0 until length) {
134- longs[i] = this .readLong()
129+ val longs = LongArray (length) {
130+ this .readLong()
135131 }
136132
137133 return @checkTimeout TagLongArray (longs)
0 commit comments