Remove expensive TRACE logging
```
benchmark old ns/op new ns/op delta
BenchmarkTooBool-4 2671 67.8 -97.46%
benchmark old allocs new allocs delta
BenchmarkTooBool-4 3 1 -66.67%
benchmark old bytes new bytes delta
BenchmarkTooBool-4 49 1 -97.96%
```
diff --git a/.gitignore b/.gitignore
index 8365624..53053a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,5 @@
*.exe
*.test
+
+*.bench
diff --git a/caste.go b/caste.go
index 38d03de..23f59a1 100644
--- a/caste.go
+++ b/caste.go
@@ -12,14 +12,11 @@
"strconv"
"strings"
"time"
-
- jww "github.com/spf13/jwalterweatherman"
)
// ToTimeE casts an empty interface to time.Time.
func ToTimeE(i interface{}) (tim time.Time, err error) {
i = indirect(i)
- jww.TRACE.Println("ToTimeE called on type:", reflect.TypeOf(i))
switch s := i.(type) {
case time.Time:
@@ -38,7 +35,6 @@
// ToDurationE casts an empty interface to time.Duration.
func ToDurationE(i interface{}) (d time.Duration, err error) {
i = indirect(i)
- jww.TRACE.Println("ToDurationE called on type:", reflect.TypeOf(i))
switch s := i.(type) {
case time.Duration:
@@ -64,8 +60,8 @@
// ToBoolE casts an empty interface to a bool.
func ToBoolE(i interface{}) (bool, error) {
+
i = indirect(i)
- jww.TRACE.Println("ToBoolE called on type:", reflect.TypeOf(i))
switch b := i.(type) {
case bool:
@@ -87,7 +83,6 @@
// ToFloat64E casts an empty interface to a float64.
func ToFloat64E(i interface{}) (float64, error) {
i = indirect(i)
- jww.TRACE.Println("ToFloat64E called on type:", reflect.TypeOf(i))
switch s := i.(type) {
case float64:
@@ -118,7 +113,6 @@
// ToInt64E casts an empty interface to an int64.
func ToInt64E(i interface{}) (int64, error) {
i = indirect(i)
- jww.TRACE.Println("ToInt64E called on type:", reflect.TypeOf(i))
switch s := i.(type) {
case int64:
@@ -154,7 +148,6 @@
// ToIntE casts an empty interface to an int.
func ToIntE(i interface{}) (int, error) {
i = indirect(i)
- jww.TRACE.Println("ToIntE called on type:", reflect.TypeOf(i))
switch s := i.(type) {
case int:
@@ -229,7 +222,6 @@
// ToStringE casts an empty interface to a string.
func ToStringE(i interface{}) (string, error) {
i = indirectToStringerOrError(i)
- jww.TRACE.Println("ToStringE called on type:", reflect.TypeOf(i))
switch s := i.(type) {
case string:
@@ -267,7 +259,6 @@
// ToStringMapStringE casts an empty interface to a map[string]string.
func ToStringMapStringE(i interface{}) (map[string]string, error) {
- jww.TRACE.Println("ToStringMapStringE called on type:", reflect.TypeOf(i))
var m = map[string]string{}
@@ -296,7 +287,6 @@
// ToStringMapStringSliceE casts an empty interface to a map[string][]string.
func ToStringMapStringSliceE(i interface{}) (map[string][]string, error) {
- jww.TRACE.Println("ToStringMapStringSliceE called on type:", reflect.TypeOf(i))
var m = map[string][]string{}
@@ -359,7 +349,6 @@
// ToStringMapBoolE casts an empty interface to a map[string]bool.
func ToStringMapBoolE(i interface{}) (map[string]bool, error) {
- jww.TRACE.Println("ToStringMapBoolE called on type:", reflect.TypeOf(i))
var m = map[string]bool{}
@@ -383,7 +372,6 @@
// ToStringMapE casts an empty interface to a map[string]interface{}.
func ToStringMapE(i interface{}) (map[string]interface{}, error) {
- jww.TRACE.Println("ToStringMapE called on type:", reflect.TypeOf(i))
var m = map[string]interface{}{}
@@ -402,7 +390,6 @@
// ToSliceE casts an empty interface to a []interface{}.
func ToSliceE(i interface{}) ([]interface{}, error) {
- jww.TRACE.Println("ToSliceE called on type:", reflect.TypeOf(i))
var s []interface{}
@@ -424,7 +411,6 @@
// ToBoolSliceE casts an empty interface to a []bool.
func ToBoolSliceE(i interface{}) ([]bool, error) {
- jww.DEBUG.Println("ToBoolSliceE called on type:", reflect.TypeOf(i))
if i == nil {
return []bool{}, fmt.Errorf("Unable to Cast %#v to []bool", i)
@@ -453,10 +439,8 @@
}
}
-
// ToStringSliceE casts an empty interface to a []string.
func ToStringSliceE(i interface{}) ([]string, error) {
- jww.TRACE.Println("ToStringSliceE called on type:", reflect.TypeOf(i))
var a []string
@@ -483,7 +467,6 @@
// ToIntSliceE casts an empty interface to a []int.
func ToIntSliceE(i interface{}) ([]int, error) {
- jww.TRACE.Println("ToIntSliceE called on type:", reflect.TypeOf(i))
if i == nil {
return []int{}, fmt.Errorf("Unable to Cast %#v to []int", i)