Benchmark against other libraries (#175)
BenchmarkUnmarshalToml-8 1000 1320117 ns/op 450932 B/op 15072 allocs/op BenchmarkUnmarshalBurntSushiToml-8 3000 402897 ns/op 82900 B/op 1761 allocs/op BenchmarkUnmarshalJson-8 20000 66092 ns/op 3536 B/op 101 allocs/op BenchmarkUnmarshalYaml-8 10000 189600 ns/op 44872 B/op 1058 allocs/op
This commit is contained in:
+8
-3
@@ -268,15 +268,20 @@ func valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value, error) {
|
||||
mtypef := mtype.Field(i)
|
||||
opts := tomlOptions(mtypef)
|
||||
if opts.include {
|
||||
key := opts.name
|
||||
exists := tval.Has(key)
|
||||
if exists {
|
||||
baseKey := opts.name
|
||||
keysToTry := []string{baseKey, strings.ToLower(baseKey), strings.ToTitle(baseKey)}
|
||||
for _, key := range keysToTry {
|
||||
exists := tval.Has(key)
|
||||
if !exists {
|
||||
continue
|
||||
}
|
||||
val := tval.Get(key)
|
||||
mvalf, err := valueFromToml(mtypef.Type, val)
|
||||
if err != nil {
|
||||
return mval, formatError(err, tval.GetPosition(key))
|
||||
}
|
||||
mval.Field(i).Set(mvalf)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user