Package: golang-fortio-safecast / 1.2.0-2

Metadata

Package Version Patches format
golang-fortio-safecast 1.2.0-2 3.0 (quilt)

Patch series

view the series file
Patch File delta Description
0001 Do not use reflect to check if Number is float.patch | (download)

safecast.go | 5 2 + 3 - 0 !
safecast_test.go | 12 12 + 0 - 0 !
2 files changed, 14 insertions(+), 3 deletions(-)

 do not use reflect to check if number is float

This allows to get rid of the reflect dependencies and also makes the
code run a bit faster.

Before:
	$ go test -bench=.
	goos: linux
	goarch: amd64
	pkg: fortio.org/safecast
	cpu: 13th Gen Intel(R) Core(TM) i9-13900
	BenchmarkMustConvert_float64_int8-32    	560162847	         2.004 ns/op
	BenchmarkMustConvert_int_int8-32        	738659530	         1.619 ns/op
	PASS
	ok  	fortio.org/safecast	2.322s

After:
	$ go test -bench=.
	goos: linux
	goarch: amd64
	pkg: fortio.org/safecast
	cpu: 13th Gen Intel(R) Core(TM) i9-13900
	BenchmarkMustConvert_float64_int8-32    	597861529	         1.844 ns/op
	BenchmarkMustConvert_int_int8-32        	831054811	         1.438 ns/op
	PASS
	ok  	fortio.org/safecast	2.304s