Skip to content
This repository was archived by the owner on Nov 21, 2023. It is now read-only.

Commit fcffa84

Browse files
implemented TagsLen and PCLen methods. reduced erf.top usage.
1 parent 40581ca commit fcffa84

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

erf.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (e *Erf) Fmt() string {
163163
return e.format
164164
}
165165

166-
// Len returns the length of the arguments slice.
166+
// Len returns the length of arguments.
167167
func (e *Erf) Len() int {
168168
return len(e.args)
169169
}
@@ -225,6 +225,11 @@ func (e *Erf) Attach2(tags ...string) error {
225225
return e.Attach(tags...)
226226
}
227227

228+
// TagsLen returns the length of tags.
229+
func (e *Erf) TagsLen() int {
230+
return len(e.tags)
231+
}
232+
228233
// Tag returns an argument value on the given tag. It returns nil if tag is not found.
229234
func (e *Erf) Tag(tag string) interface{} {
230235
index := -1
@@ -247,14 +252,18 @@ func (e *Erf) Tags() []string {
247252
return result
248253
}
249254

250-
// PC returns program counters.
255+
// PC returns all program counters.
251256
func (e *Erf) PC() []uintptr {
252-
src := e.pc[e.top:]
253-
result := make([]uintptr, len(src))
254-
copy(result, src)
257+
result := make([]uintptr, len(e.pc))
258+
copy(result, e.pc)
255259
return result
256260
}
257261

262+
// PCLen returns the length of all program counters.
263+
func (e *Erf) PCLen() int {
264+
return len(e.pc)
265+
}
266+
258267
// StackTrace returns a StackTrace of Erf.
259268
func (e *Erf) StackTrace() *StackTrace {
260269
return NewStackTrace(e.pc[e.top:]...)

stack.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@ func (t *StackTrace) Len() int {
164164

165165
// Caller returns a StackCaller on the given index. It panics if index is out of range.
166166
func (t *StackTrace) Caller(index int) StackCaller {
167-
if t.Len() <= 0 {
168-
return StackCaller{}
169-
}
170167
if index < 0 || index >= t.Len() {
171168
panic("index out of range")
172169
}

0 commit comments

Comments
 (0)