Moar PR improvements
@@ -5,18 +5,16 @@ package internal
import "runtime"
func (st StackTrace) frames() []stacktraceFrame {
- fs := make([]stacktraceFrame, len(st))
+ fs := make([]stacktraceFrame, maxStackTraceFrames)
frames := runtime.CallersFrames(st)
- for i := range st {
- frame, more := frames.Next()
+ i := 0
+ for frame, more := frames.Next(); more && (i < maxStackTraceFrames); frame, more = frames.Next() {
fs[i] = stacktraceFrame{
Name: frame.Function,
File: frame.File,
Line: int64(frame.Line),
}
- if !more {
- break
+ i++
}
- }
- return fs
+ return fs[0:i]
}
