Skip to content

Commit

Permalink
use strconv.v_sprintf inside unsafe {} blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Jul 10, 2023
1 parent 2fd2cff commit b9f4776
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion la/matrix.v
Original file line number Diff line number Diff line change
Expand Up @@ -377,5 +377,5 @@ pub fn (o &Matrix[T]) print_py(nfmt_ string) string {

[inline]
pub fn safe_print[T](format string, message T) string {
return strconv.v_sprintf(format, message)
return unsafe { strconv.v_sprintf(format, message) }
}
12 changes: 6 additions & 6 deletions vlas/conversions.v
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn print_col_major(m int, n int, data []f64, nfmt_ string) string {
l += '\n'
}
for j in 0 .. n {
l += strconv.v_sprintf(nfmt, data[i + j * m])
l += unsafe { strconv.v_sprintf(nfmt, data[i + j * m]) }
}
}
return l
Expand All @@ -93,7 +93,7 @@ pub fn print_col_major_v(m int, n int, data []f64, nfmt_ string) string {
if j > 0 {
l += ','
}
l += strconv.v_sprintf(nfmt, data[i + j * m])
l += unsafe { strconv.v_sprintf(nfmt, data[i + j * m]) }
}
l += '},\n'
}
Expand All @@ -114,7 +114,7 @@ pub fn print_col_major_py(m int, n int, data []f64, nfmt_ string) string {
if j > 0 {
l += ','
}
l += strconv.v_sprintf(nfmt, data[i + j * m])
l += unsafe { strconv.v_sprintf(nfmt, data[i + j * m]) }
}
l += '],\n'
}
Expand Down Expand Up @@ -177,7 +177,7 @@ pub fn print_col_major_complex(m int, n int, data []complex.Complex, nfmt_r_ str
l += ', '
}
v := data[i + j * m]
l += strconv.v_sprintf(nfmt_r, v.re) + strconv.v_sprintf(nfmt_i, v.im) + 'i'
l += unsafe { strconv.v_sprintf(nfmt_r, v.re) + strconv.v_sprintf(nfmt_i, v.im) + 'i' }
}
}
return l
Expand Down Expand Up @@ -205,7 +205,7 @@ pub fn print_col_major_complex_v(m int, n int, data []complex.Complex, nfmt_r_ s
l += ','
}
v := data[i + j * m]
l += strconv.v_sprintf(nfmt_r, v.re) + strconv.v_sprintf(nfmt_i, v.im) + 'i'
l += unsafe { strconv.v_sprintf(nfmt_r, v.re) + strconv.v_sprintf(nfmt_i, v.im) + 'i' }
}
l += '},\n'
}
Expand Down Expand Up @@ -235,7 +235,7 @@ pub fn print_col_major_omplex_py(m int, n int, data []complex.Complex, nfmt_r_ s
l += ','
}
v := data[i + j * m]
l += strconv.v_sprintf(nfmt_r, v.re) + strconv.v_sprintf(nfmt_i, v.im) + 'j'
l += unsafe { strconv.v_sprintf(nfmt_r, v.re) + strconv.v_sprintf(nfmt_i, v.im) + 'j' }
}
l += '],\n'
}
Expand Down

0 comments on commit b9f4776

Please sign in to comment.