aboutsummaryrefslogtreecommitdiff
path: root/object.go
diff options
context:
space:
mode:
authorMarius Orcsik2022-06-04 19:19:30 +0200
committerMarius Orcsik2022-06-04 19:19:30 +0200
commit697681d8d45628270e5742b66730eef1c65ee07a (patch)
treec36a49712e4772d81592d8fc795226aeabc2baff /object.go
parent6917e06269f57792ea1ad6ea79556cc772df48eb (diff)
Added benchmarks for 'ToXX' vs 'To[T type]'
They show some weird numbers considering the 'On' benchmarks
Diffstat (limited to 'object.go')
-rw-r--r--object.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/object.go b/object.go
index 93d48e3..f7a11fb 100644
--- a/object.go
+++ b/object.go
@@ -676,6 +676,9 @@ func ToObject(it Item) (*Object, error) {
// NOTE(marius): this is an ugly way of dealing with the interface conversion error: types from different scopes
typ := reflect.TypeOf(new(Object))
if reflect.TypeOf(it).ConvertibleTo(typ) {
+ if reflect.ValueOf(it).IsNil() {
+ return nil, nil
+ }
if i, ok := reflect.ValueOf(it).Convert(typ).Interface().(*Object); ok {
return i, nil
}