Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit c38ea53

Browse files
authored
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 <[email protected]>
1 parent c9e70be commit c38ea53

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

stack.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,25 @@ func (f Frame) format(w io.Writer, s fmt.State, verb rune) {
3535
case 's':
3636
switch {
3737
case s.Flag('+'):
38-
fn := runtime.Frame(f).Func
38+
fn := f.Func
3939
if fn == nil {
4040
io.WriteString(w, "unknown")
4141
} else {
42-
file := runtime.Frame(f).File
4342
io.WriteString(w, fn.Name())
4443
io.WriteString(w, "\n\t")
45-
io.WriteString(w, file)
44+
io.WriteString(w, f.File)
4645
}
4746
default:
48-
file := runtime.Frame(f).File
47+
file := f.File
4948
if file == "" {
5049
file = "unknown"
5150
}
5251
io.WriteString(w, path.Base(file))
5352
}
5453
case 'd':
55-
io.WriteString(w, strconv.Itoa(runtime.Frame(f).Line))
54+
io.WriteString(w, strconv.Itoa(f.Line))
5655
case 'n':
57-
name := runtime.Frame(f).Function
56+
name := f.Function
5857
io.WriteString(s, funcname(name))
5958
case 'v':
6059
f.format(w, s, 's')

0 commit comments

Comments
 (0)