File tree 5 files changed +30
-4
lines changed
5 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,18 @@ testv:
45
45
test :
46
46
$(GO ) test $(TEST_ARGS ) $(PKGS )
47
47
48
+ inline_err2 :
49
+ $(GO ) test -c -gcflags=-m=2 $(PKG_ERR2 ) 2>&1 | ag ' inlin'
50
+
51
+ tinline_err2 :
52
+ $(GO ) test -c -gcflags=-m=2 $(PKG_ERR2 ) 2>&1 | ag ' inlin' | ag ' err2_test'
53
+
54
+ inline_handler :
55
+ $(GO ) test -c -gcflags=-m=2 $(PKG_HANDLER ) 2>&1 | ag ' inlin'
56
+
57
+ tinline_handler :
58
+ $(GO ) test -c -gcflags=-m=2 $(PKG_HANDLER ) 2>&1 | ag ' inlin'
59
+
48
60
bench :
49
61
$(GO ) test -bench=. $(PKGS )
50
62
@@ -69,6 +81,9 @@ bench_that:
69
81
bench_copy :
70
82
$(GO ) test -bench=' Benchmark_CopyBuffer' $(PKG_TRY )
71
83
84
+ bench_rece :
85
+ $(GO ) test -bench=' BenchmarkRecursionWithTryAnd_Empty_Defer' $(PKG_ERR2 )
86
+
72
87
bench_rec :
73
88
$(GO ) test -bench=' BenchmarkRecursionWithOldErrorIfCheckAnd_Defer' $(PKG_ERR2 )
74
89
Original file line number Diff line number Diff line change @@ -431,8 +431,11 @@ Please see the full version history from [CHANGELOG](./CHANGELOG.md).
431
431
432
432
##### 0.9.40
433
433
- Huge performance boost for: ` defer err2.Handle /Catch ()`
434
- - **3x faster happy path**, tested 100 deep call stack with every lvl has ` defer `
435
- - solution caused change to API (core reason is Go's optimization "bug")
434
+ - **3x faster happy path than the previous version, which is now equal to
435
+ simplest ` defer ` function in the err-returning function** . (Please see the
436
+ ` defer ` benchmarks in the ` err2_test.go ` and run ` make bench_reca` )
437
+ - the solution caused a change to API, where the core reason is Go's
438
+ optimization "bug". (We don't have confirmation yet)
436
439
- Changed API for deferred error handling: ` defer err2.Handle /Catch ()`
437
440
- deprecated:
438
441
` ` ` go
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ func Init() {
30
30
}
31
31
32
32
func doMainAll () {
33
+ Init ()
34
+
33
35
logger .Info ("=== 1. preferred successful status output ===" )
34
36
doMain1 ()
35
37
logger .Info ("=== 2. NilThen and try.To successful status ===" )
@@ -46,7 +48,10 @@ func doMainAll() {
46
48
logger .Info ("=== 3. NilThen and try.Out successful status ===" )
47
49
doMain3 ()
48
50
}
51
+
49
52
func doMain3 () {
53
+ Init ()
54
+
50
55
defer err2 .Catch ("CATCH" )
51
56
logger .Debug ("3: ADD node" )
52
57
defer NilThen (func () {
@@ -56,6 +61,8 @@ func doMain3() {
56
61
}
57
62
58
63
func doMain2 () {
64
+ Init ()
65
+
59
66
defer err2 .Catch ("CATCH" )
60
67
logger .Debug ("2: ADD node" )
61
68
defer NilThen (func () {
@@ -66,6 +73,8 @@ func doMain2() {
66
73
}
67
74
68
75
func doMain1 () {
76
+ Init ()
77
+
69
78
defer err2 .Catch ("CATCH" )
70
79
logger .Debug ("1: ADD node" )
71
80
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ func OrgCopyFile(src, dst string) (err error) {
56
56
return fmt .Errorf ("mixing traditional error checking: %w" , err )
57
57
}
58
58
defer err2 .Handle (& err , func () {
59
- os .Remove (dst )
59
+ try . Out ( os .Remove (dst )). Logf ( "cleaning error" )
60
60
})
61
61
defer w .Close ()
62
62
try .To1 (io .Copy (w , r ))
Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ func main() {
17
17
log .SetFlags (log .Lshortfile | log .LstdFlags )
18
18
19
19
flag .Parse ()
20
- Init ()
21
20
22
21
switch * mode {
23
22
case "db" :
You can’t perform that action at this time.
0 commit comments