pingcap / failpoint

An implementation of failpoints for Golang.
Apache License 2.0
817 stars 63 forks source link

code: optimize empty function generated code #27

Closed lonng closed 5 years ago

lonng commented 5 years ago

Signed-off-by: Lonng chris@lonng.org

What problem does this PR solve?

Empty function will cause line number inconsistent, e.g

failpoint.Inject("LoadDataSlowDown", func() {})
// GENERATE
if _, ok := failpoint.Eval(_curpkg_("LoadDataSlowDown")); ok {
}

// TO KEEP LINE NUMBER CONSISTENT
failpoint.Inject("LoadDataSlowDown", nil)
// GENERATE
failpoint.Eval(_curpkg_("LoadDataSlowDown"))

What is changed and how it works?

Make empty function and nil function generate same code.

Check List

Tests

Side effects

Related changes

codecov[bot] commented 5 years ago

Codecov Report

Merging #27 into master will not change coverage. The diff coverage is 100%.

@@             Coverage Diff             @@
##             master        #27   +/-   ##
===========================================
  Coverage   86.9169%   86.9169%           
===========================================
  Files             7          7           
  Lines           879        879           
===========================================
  Hits            764        764           
  Misses           73         73           
  Partials         42         42