Skip to content

Commit 92f0b89

Browse files
JosephTLyonslpil
authored andcommitted
Use % and / over bitwise operations
1 parent 3f26c57 commit 92f0b89

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/gleam/string.gleam

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//// Strings in Gleam are UTF-8 binaries. They can be written in your code as
22
//// text surrounded by `"double quotes"`.
33

4-
import gleam/int
54
import gleam/list
65
import gleam/option.{type Option, None, Some}
76
import gleam/order
@@ -429,11 +428,11 @@ fn repeat_loop(
429428
doubling_acc: String,
430429
acc: String,
431430
) -> String {
432-
let acc = case int.bitwise_and(times, 1) {
431+
let acc = case times % 2 {
433432
0 -> acc
434433
_ -> acc <> doubling_acc
435434
}
436-
let times = int.bitwise_shift_right(times, 1)
435+
let times = times / 2
437436
case times <= 0 {
438437
True -> acc
439438
False -> repeat_loop(string, times, doubling_acc <> doubling_acc, acc)

0 commit comments

Comments
 (0)