vlib: remove negative checks on unsigned (#1728)

pull/1742/head
Henrixounez 2019-08-25 00:48:38 +02:00 committed by Alexander Medvednikov
parent a62e6b127a
commit f22d5c5624
1 changed files with 0 additions and 30 deletions

View File

@ -76,11 +76,6 @@ pub fn (nn u32) str() string {
max := 16
mut buf := malloc(max)
mut len := 0
mut is_neg := false
if n < u32(0) {
n = -n
is_neg = true
}
// Fill the string from the end
for n > u32(0) {
d := n % u32(10)
@ -88,11 +83,6 @@ pub fn (nn u32) str() string {
len++
n = n / u32(10)
}
// Prepend - if it's negative
if is_neg {
buf[max - len - 1] = `-`
len++
}
return tos(buf + max - len, len)
}
@ -104,11 +94,6 @@ pub fn (nn u8) str() string {
max := 5
mut buf := malloc(max)
mut len := 0
mut is_neg := false
if n < u8(0) {
n = -n
is_neg = true
}
// Fill the string from the end
for n > u8(0) {
d := n % u8(10)
@ -116,11 +101,6 @@ pub fn (nn u8) str() string {
len++
n = n / u8(10)
}
// Prepend - if it's negative
if is_neg {
buf[max - len - 1] = `-`
len++
}
return tos(buf + max - len, len)
}
@ -160,11 +140,6 @@ pub fn (nn u64) str() string {
max := 32
mut buf := malloc(max)
mut len := 0
mut is_neg := false
if n < u64(0) {
n = -n
is_neg = true
}
// Fill the string from the end
for n > u64(0) {
d := n % u64(10)
@ -172,11 +147,6 @@ pub fn (nn u64) str() string {
len++
n = n / u64(10)
}
// Prepend - if it's negative
if is_neg {
buf[max - len - 1] = `-`
len++
}
return tos(buf + max - len, len)
}