Skip to content

Commit 449f457

Browse files
committed
use property id as a key
benchmark old ns/op new ns/op delta BenchmarkAllocProperty/props0 83.3 83.4 +0.12% BenchmarkAllocProperty/props1 296 254 -14.19% BenchmarkAllocProperty/props2 606 492 -18.81% BenchmarkAllocProperty/props3 1009 804 -20.32% BenchmarkAllocProperty/props4 1439 1112 -22.72% BenchmarkAllocProperty/props5 1952 1503 -23.00% BenchmarkAllocProperty/props6 2486 1866 -24.94% BenchmarkAllocProperty/props7 3115 2322 -25.46% BenchmarkAllocProperty/props8 3751 2733 -27.14% benchmark old allocs new allocs delta BenchmarkAllocProperty/props0 1 1 +0.00% BenchmarkAllocProperty/props1 4 4 +0.00% BenchmarkAllocProperty/props2 7 7 +0.00% BenchmarkAllocProperty/props3 10 10 +0.00% BenchmarkAllocProperty/props4 13 13 +0.00% BenchmarkAllocProperty/props5 16 16 +0.00% BenchmarkAllocProperty/props6 19 19 +0.00% BenchmarkAllocProperty/props7 22 22 +0.00% BenchmarkAllocProperty/props8 25 25 +0.00% benchmark old bytes new bytes delta BenchmarkAllocProperty/props0 96 96 +0.00% BenchmarkAllocProperty/props1 592 448 -24.32% BenchmarkAllocProperty/props2 1088 800 -26.47% BenchmarkAllocProperty/props3 1584 1152 -27.27% BenchmarkAllocProperty/props4 2080 1504 -27.69% BenchmarkAllocProperty/props5 2576 1856 -27.95% BenchmarkAllocProperty/props6 3072 2208 -28.12% BenchmarkAllocProperty/props7 3568 2560 -28.25% BenchmarkAllocProperty/props8 4064 2912 -28.35%
1 parent ae2cee4 commit 449f457

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

error.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type Error struct {
1616
underlying []error
1717
stackTrace *stackTrace
1818
transparent bool
19-
properties map[Property]interface{}
19+
properties map[int64]interface{}
2020
}
2121

2222
var _ fmt.Formatter = (*Error)(nil)
@@ -29,15 +29,15 @@ func (e *Error) WithProperty(key Property, value interface{}) *Error {
2929
errorCopy := *e
3030

3131
if errorCopy.properties == nil {
32-
errorCopy.properties = make(map[Property]interface{}, 1)
32+
errorCopy.properties = make(map[int64]interface{}, 1)
3333
} else {
34-
errorCopy.properties = make(map[Property]interface{}, len(e.properties) + 1)
34+
errorCopy.properties = make(map[int64]interface{}, len(e.properties)+1)
3535
for k, v := range e.properties {
3636
errorCopy.properties[k] = v
3737
}
3838
}
3939

40-
errorCopy.properties[key] = value
40+
errorCopy.properties[key.id] = value
4141
return &errorCopy
4242
}
4343

@@ -47,7 +47,7 @@ func (e *Error) WithProperty(key Property, value interface{}) *Error {
4747
func (e *Error) WithUnderlyingErrors(errs ...error) *Error {
4848
errorCopy := *e
4949

50-
newUnderying := make([]error, 0, len(e.underlying) + len(errs))
50+
newUnderying := make([]error, 0, len(e.underlying)+len(errs))
5151
newUnderying = append(newUnderying, e.underlying...)
5252

5353
for _, err := range errs {
@@ -69,7 +69,7 @@ func (e *Error) WithUnderlyingErrors(errs ...error) *Error {
6969
func (e *Error) Property(key Property) (interface{}, bool) {
7070
cause := e
7171
for cause != nil {
72-
value, ok := cause.properties[key]
72+
value, ok := cause.properties[key.id]
7373
if ok {
7474
return value, true
7575
}

0 commit comments

Comments
 (0)