Skip to content

Commit 0107a61

Browse files
committed
Ride off useless 0xff
1 parent 08c42ec commit 0107a61

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

shared/src/main/scala/ky/korins/blake3/Output.scala

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,31 @@ private[blake3] class Output(
5858
wordIdx += 1
5959
lim - pos match {
6060
case 1 =>
61-
out(pos) = (word & 0xff).toByte
61+
out(pos) = word.toByte
6262
pos += 1
6363

6464
case 2 =>
65-
out(pos) = (word & 0xff).toByte
65+
out(pos) = word.toByte
6666
pos += 1
67-
out(pos) = ((word >>> 8) & 0xff).toByte
67+
out(pos) = (word >>> 8).toByte
6868
pos += 1
6969

7070
case 3 =>
71-
out(pos) = (word & 0xff).toByte
71+
out(pos) = word.toByte
7272
pos += 1
73-
out(pos) = ((word >>> 8) & 0xff).toByte
73+
out(pos) = (word >>> 8).toByte
7474
pos += 1
75-
out(pos) = ((word >>> 16) & 0xff).toByte
75+
out(pos) = (word >>> 16).toByte
7676
pos += 1
7777

7878
case _ =>
79-
out(pos) = (word & 0xff).toByte
79+
out(pos) = word.toByte
8080
pos += 1
81-
out(pos) = ((word >>> 8) & 0xff).toByte
81+
out(pos) = (word >>> 8).toByte
8282
pos += 1
83-
out(pos) = ((word >>> 16) & 0xff).toByte
83+
out(pos) = (word >>> 16).toByte
8484
pos += 1
85-
out(pos) = ((word >>> 24) & 0xff).toByte
85+
out(pos) = (word >>> 24).toByte
8686
pos += 1
8787
}
8888
}
@@ -123,40 +123,40 @@ private[blake3] class Output(
123123
wordIdx += 1
124124
outLim - outPos match {
125125
case 1 =>
126-
out(outPos) = (in(inPos) ^ (word & 0xff)).toByte
126+
out(outPos) = (in(inPos) ^ word).toByte
127127
inPos += 1
128128
outPos += 1
129129

130130
case 2 =>
131-
out(outPos) = (in(inPos) ^ (word & 0xff)).toByte
131+
out(outPos) = (in(inPos) ^ word).toByte
132132
inPos += 1
133133
outPos += 1
134-
out(outPos) = (in(inPos) ^ ((word >>> 8) & 0xff)).toByte
134+
out(outPos) = (in(inPos) ^ word >>> 8).toByte
135135
inPos += 1
136136
outPos += 1
137137

138138
case 3 =>
139-
out(outPos) = (in(inPos) ^ (word & 0xff)).toByte
139+
out(outPos) = (in(inPos) ^ word).toByte
140140
inPos += 1
141141
outPos += 1
142-
out(outPos) = (in(inPos) ^ ((word >>> 8) & 0xff)).toByte
142+
out(outPos) = (in(inPos) ^ word >>> 8).toByte
143143
inPos += 1
144144
outPos += 1
145-
out(outPos) = (in(inPos) ^ ((word >>> 16) & 0xff)).toByte
145+
out(outPos) = (in(inPos) ^ word >>> 16).toByte
146146
inPos += 1
147147
outPos += 1
148148

149149
case _ =>
150-
out(outPos) = (in(inPos) ^ (word & 0xff)).toByte
150+
out(outPos) = (in(inPos) ^ word).toByte
151151
inPos += 1
152152
outPos += 1
153-
out(outPos) = (in(inPos) ^ ((word >>> 8) & 0xff)).toByte
153+
out(outPos) = (in(inPos) ^ word >>> 8).toByte
154154
inPos += 1
155155
outPos += 1
156-
out(outPos) = (in(inPos) ^ ((word >>> 16) & 0xff)).toByte
156+
out(outPos) = (in(inPos) ^ word >>> 16).toByte
157157
inPos += 1
158158
outPos += 1
159-
out(outPos) = (in(inPos) ^ ((word >>> 24) & 0xff)).toByte
159+
out(outPos) = (in(inPos) ^ word >>> 24).toByte
160160
inPos += 1
161161
outPos += 1
162162
}
@@ -328,25 +328,25 @@ private[blake3] class Output(
328328
wordIdx += 1
329329
len - pos match {
330330
case 1 =>
331-
out put (word & 0xff).toByte
331+
out put word.toByte
332332
pos += 1
333333

334334
case 2 =>
335-
out put (word & 0xff).toByte
336-
out put ((word >>> 8) & 0xff).toByte
335+
out put word.toByte
336+
out put (word >>> 8).toByte
337337
pos += 2
338338

339339
case 3 =>
340-
out put (word & 0xff).toByte
341-
out put ((word >>> 8) & 0xff).toByte
342-
out put ((word >>> 16) & 0xff).toByte
340+
out put word.toByte
341+
out put (word >>> 8).toByte
342+
out put (word >>> 16).toByte
343343
pos += 3
344344

345345
case _ =>
346-
out put (word & 0xff).toByte
347-
out put ((word >>> 8) & 0xff).toByte
348-
out put ((word >>> 16) & 0xff).toByte
349-
out put ((word >>> 24) & 0xff).toByte
346+
out put word.toByte
347+
out put (word >>> 8).toByte
348+
out put (word >>> 16).toByte
349+
out put (word >>> 24).toByte
350350
pos += 4
351351
}
352352
}
@@ -379,25 +379,25 @@ private[blake3] class Output(
379379
wordIdx += 1
380380
len - pos match {
381381
case 1 =>
382-
out put (in.get() ^ (word & 0xff)).toByte
382+
out put (in.get() ^ word).toByte
383383
pos += 1
384384

385385
case 2 =>
386-
out put (in.get() ^ (word & 0xff)).toByte
387-
out put (in.get() ^ ((word >>> 8) & 0xff)).toByte
386+
out put (in.get() ^ word).toByte
387+
out put (in.get() ^ word >>> 8).toByte
388388
pos += 2
389389

390390
case 3 =>
391-
out put (in.get() ^ (word & 0xff)).toByte
392-
out put (in.get() ^ ((word >>> 8) & 0xff)).toByte
393-
out put (in.get() ^ ((word >>> 16) & 0xff)).toByte
391+
out put (in.get() ^ word).toByte
392+
out put (in.get() ^ word >>> 8).toByte
393+
out put (in.get() ^ word >>> 16).toByte
394394
pos += 3
395395

396396
case _ =>
397-
out put (in.get() ^ (word & 0xff)).toByte
398-
out put (in.get() ^ ((word >>> 8) & 0xff)).toByte
399-
out put (in.get() ^ ((word >>> 16) & 0xff)).toByte
400-
out put (in.get() ^ ((word >>> 24) & 0xff)).toByte
397+
out put (in.get() ^ word).toByte
398+
out put (in.get() ^ word >>> 8).toByte
399+
out put (in.get() ^ word >>> 16).toByte
400+
out put (in.get() ^ word >>> 24).toByte
401401
pos += 4
402402
}
403403
}

0 commit comments

Comments
 (0)