From c38ea53d8c3f78ac85b9b0f1247abeb6d38f6988 Mon Sep 17 00:00:00 2001 From: Dave Cheney Date: Sun, 6 Jan 2019 12:53:32 +1100 Subject: [PATCH] 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 --- stack.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/stack.go b/stack.go index e5d6847..3b582c2 100644 --- a/stack.go +++ b/stack.go @@ -35,26 +35,25 @@ func (f Frame) format(w io.Writer, s fmt.State, verb rune) { case 's': switch { case s.Flag('+'): - fn := runtime.Frame(f).Func + fn := f.Func if fn == nil { io.WriteString(w, "unknown") } else { - file := runtime.Frame(f).File io.WriteString(w, fn.Name()) io.WriteString(w, "\n\t") - io.WriteString(w, file) + io.WriteString(w, f.File) } default: - file := runtime.Frame(f).File + file := f.File if file == "" { file = "unknown" } io.WriteString(w, path.Base(file)) } case 'd': - io.WriteString(w, strconv.Itoa(runtime.Frame(f).Line)) + io.WriteString(w, strconv.Itoa(f.Line)) case 'n': - name := runtime.Frame(f).Function + name := f.Function io.WriteString(s, funcname(name)) case 'v': f.format(w, s, 's')