Skip to content

Commit

Permalink
Missed formatting updates
Browse files Browse the repository at this point in the history
  • Loading branch information
smores56 committed Jan 5, 2025
1 parent 865a399 commit e737192
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 34 deletions.
36 changes: 18 additions & 18 deletions crates/cli/tests/benchmarks/Base64/Decode.roc
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ loop_help = \{ remaining, string } ->
if remaining >= 3 then
Bytes.Decode.map3(Bytes.Decode.u8, Bytes.Decode.u8, Bytes.Decode.u8, \x, y, z ->
a : U32
a = Num.intCast(x)
a = Num.int_cast(x)
b : U32
b = Num.intCast(y)
b = Num.int_cast(y)
c : U32
c = Num.intCast(z)
combined = Num.bitwiseOr(Num.bitwiseOr(Num.shiftLeftBy(a, 16), Num.shiftLeftBy(b, 8)), c)
c = Num.int_cast(z)
combined = Num.bitwise_or(Num.bitwise_or(Num.shift_left_by(a, 16), Num.shift_left_by(b, 8)), c)

Loop({
remaining: remaining - 3,
Expand All @@ -31,24 +31,24 @@ loop_help = \{ remaining, string } ->
Bytes.Decode.map2(Bytes.Decode.u8, Bytes.Decode.u8, \x, y ->

a : U32
a = Num.intCast(x)
a = Num.int_cast(x)
b : U32
b = Num.intCast(y)
combined = Num.bitwiseOr(Num.shiftLeftBy(a, 16), Num.shiftLeftBy(b, 8))
b = Num.int_cast(y)
combined = Num.bitwise_or(Num.shift_left_by(a, 16), Num.shift_left_by(b, 8))

Done(Str.concat(string, bits_to_chars(combined, 1))))
else
# remaining = 1
Bytes.Decode.map(Bytes.Decode.u8, \x ->

a : U32
a = Num.intCast(x)
a = Num.int_cast(x)

Done(Str.concat(string, bits_to_chars(Num.shiftLeftBy(a, 16), 2))))
Done(Str.concat(string, bits_to_chars(Num.shift_left_by(a, 16), 2))))

bits_to_chars : U32, Int * -> Str
bits_to_chars = \bits, missing ->
when Str.fromUtf8(bits_to_chars_help(bits, missing)) is
when Str.from_utf8(bits_to_chars_help(bits, missing)) is
Ok(str) -> str
Err(_) -> ""

Expand All @@ -63,23 +63,23 @@ bits_to_chars_help = \bits, missing ->
# with `0b111111` (which is 2^6 - 1 or 63) (so, 6 1s) to remove unwanted bits on the left.
# any 6-bit number is a valid base64 digit, so this is actually safe
p =
Num.shiftRightZfBy(bits, 18)
|> Num.intCast
Num.shift_right_zf_by(bits, 18)
|> Num.int_cast
|> unsafe_to_char

q =
Num.bitwiseAnd(Num.shiftRightZfBy(bits, 12), lowest6_bits_mask)
|> Num.intCast
Num.bitwise_and(Num.shift_right_zf_by(bits, 12), lowest6_bits_mask)
|> Num.int_cast
|> unsafe_to_char

r =
Num.bitwiseAnd(Num.shiftRightZfBy(bits, 6), lowest6_bits_mask)
|> Num.intCast
Num.bitwise_and(Num.shift_right_zf_by(bits, 6), lowest6_bits_mask)
|> Num.int_cast
|> unsafe_to_char

s =
Num.bitwiseAnd(bits, lowest6_bits_mask)
|> Num.intCast
Num.bitwise_and(bits, lowest6_bits_mask)
|> Num.int_cast
|> unsafe_to_char

equals : U8
Expand Down
30 changes: 15 additions & 15 deletions crates/cli/tests/benchmarks/Base64/Encode.roc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ InvalidChar : U8
to_bytes : Str -> List U8
to_bytes = \str ->
str
|> Str.toUtf8
|> Str.to_utf8
|> encode_chunks
|> Bytes.Encode.sequence
|> Bytes.Encode.encode
Expand Down Expand Up @@ -73,18 +73,18 @@ encode_characters = \a, b, c, d ->
n2 = unsafe_convert_char(b)

x : U32
x = Num.intCast(n1)
x = Num.int_cast(n1)

y : U32
y = Num.intCast(n2)
y = Num.int_cast(n2)

if d == equals then
if c == equals then
n = Num.bitwiseOr(Num.shiftLeftBy(x, 18), Num.shiftLeftBy(y, 12))
n = Num.bitwise_or(Num.shift_left_by(x, 18), Num.shift_left_by(y, 12))

# masking higher bits is not needed, Encode.unsignedInt8 ignores higher bits
b1 : U8
b1 = Num.intCast(Num.shiftRightBy(n, 16))
b1 = Num.int_cast(Num.shift_right_by(n, 16))

Ok(Bytes.Encode.u8(b1))
else if !(is_valid_char(c)) then
Expand All @@ -93,12 +93,12 @@ encode_characters = \a, b, c, d ->
n3 = unsafe_convert_char(c)

z : U32
z = Num.intCast(n3)
z = Num.int_cast(n3)

n = Num.bitwiseOr(Num.bitwiseOr(Num.shiftLeftBy(x, 18), Num.shiftLeftBy(y, 12)), Num.shiftLeftBy(z, 6))
n = Num.bitwise_or(Num.bitwise_or(Num.shift_left_by(x, 18), Num.shift_left_by(y, 12)), Num.shift_left_by(z, 6))

combined : U16
combined = Num.intCast(Num.shiftRightBy(n, 8))
combined = Num.int_cast(Num.shift_right_by(n, 8))

Ok(Bytes.Encode.u16(BE, combined))
else if !(is_valid_char(d)) then
Expand All @@ -108,22 +108,22 @@ encode_characters = \a, b, c, d ->
n4 = unsafe_convert_char(d)

z : U32
z = Num.intCast(n3)
z = Num.int_cast(n3)

w : U32
w = Num.intCast(n4)
w = Num.int_cast(n4)

n =
Num.bitwiseOr(
Num.bitwiseOr(Num.shiftLeftBy(x, 18), Num.shiftLeftBy(y, 12)),
Num.bitwiseOr(Num.shiftLeftBy(z, 6), w),
Num.bitwise_or(
Num.bitwise_or(Num.shift_left_by(x, 18), Num.shift_left_by(y, 12)),
Num.bitwise_or(Num.shift_left_by(z, 6), w),
)

b3 : U8
b3 = Num.intCast(n)
b3 = Num.int_cast(n)

combined : U16
combined = Num.intCast(Num.shiftRightBy(n, 8))
combined = Num.int_cast(Num.shift_right_by(n, 8))

Ok(Bytes.Encode.sequence([Bytes.Encode.u16(BE, combined), Bytes.Encode.u8(b3)]))

Expand Down
2 changes: 1 addition & 1 deletion crates/cli/tests/benchmarks/platform/main.roc
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ platform "benchmarks"
provides [main_for_host!]

main_for_host! : {} => {}
main_for_host! = \{} -> main! {}
main_for_host! = \{} -> main!({})

0 comments on commit e737192

Please sign in to comment.