Remove errors.Frame to runtime.Frame conversions (#189)

Avoid the unnecessary conversions from errors.Frame to
runtime.Frame to access the latter's fields as by definition the former
also has the same fields.

Signed-off-by: Dave Cheney <dave@cheney.net>
pull/175/head^2
Dave Cheney 2019-01-06 12:53:32 +11:00 committed by GitHub
parent c9e70be240
commit c38ea53d8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 6 deletions

View File

@ -35,26 +35,25 @@ func (f Frame) format(w io.Writer, s fmt.State, verb rune) {
case 's': case 's':
switch { switch {
case s.Flag('+'): case s.Flag('+'):
fn := runtime.Frame(f).Func fn := f.Func
if fn == nil { if fn == nil {
io.WriteString(w, "unknown") io.WriteString(w, "unknown")
} else { } else {
file := runtime.Frame(f).File
io.WriteString(w, fn.Name()) io.WriteString(w, fn.Name())
io.WriteString(w, "\n\t") io.WriteString(w, "\n\t")
io.WriteString(w, file) io.WriteString(w, f.File)
} }
default: default:
file := runtime.Frame(f).File file := f.File
if file == "" { if file == "" {
file = "unknown" file = "unknown"
} }
io.WriteString(w, path.Base(file)) io.WriteString(w, path.Base(file))
} }
case 'd': case 'd':
io.WriteString(w, strconv.Itoa(runtime.Frame(f).Line)) io.WriteString(w, strconv.Itoa(f.Line))
case 'n': case 'n':
name := runtime.Frame(f).Function name := f.Function
io.WriteString(s, funcname(name)) io.WriteString(s, funcname(name))
case 'v': case 'v':
f.format(w, s, 's') f.format(w, s, 's')