Skip to content

Commit 92eb6cf

Browse files
committed
strings: special case min_i64 in write_decimal, so the common case calculations could be still done with signed integers
1 parent fb52cd9 commit 92eb6cf

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

vlib/strings/builder.c.v

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,13 @@ pub fn (mut b Builder) write_decimal(n i64) {
8080
b.write_u8(0x30)
8181
return
8282
}
83+
if n == min_i64 {
84+
b.write_string(n.str())
85+
return
86+
}
87+
8388
mut buf := [25]u8{}
84-
mut x := if n < 0 { u64(-n) } else { u64(n) }
89+
mut x := if n < 0 { -n } else { n }
8590
mut i := 24
8691
for x != 0 {
8792
nextx := x / 10

0 commit comments

Comments
 (0)