Skip to content

Commit

Permalink
Delete unused function
Browse files Browse the repository at this point in the history
Signed-off-by: Hang SU <darcy.sh@antfin.com>
  • Loading branch information
DarcySail committed Aug 24, 2020
1 parent 06e6051 commit f3475ed
Showing 1 changed file with 0 additions and 49 deletions.
49 changes: 0 additions & 49 deletions profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"fmt"
"go/build"
"io"
"math"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -151,54 +150,6 @@ type Boundary struct {
Norm float64 // Count normalized to [0..1].
}

// Boundaries returns a Profile as a set of Boundary objects within the provided src.
func (p *Profile) Boundaries(src []byte) (boundaries []Boundary) {
// Find maximum count.
max := 0
for _, b := range p.Blocks {
if b.Count > max {
max = b.Count
}
}
// Divisor for normalization.
divisor := math.Log(float64(max))

// boundary returns a Boundary, populating the Norm field with a normalized Count.
boundary := func(offset int, start bool, count int) Boundary {
b := Boundary{Offset: offset, Start: start, Count: count}
if !start || count == 0 {
return b
}
if max <= 1 {
b.Norm = 0.8 // Profile is in"set" mode; we want a heat map. Use cov8 in the CSS.
} else if count > 0 {
b.Norm = math.Log(float64(count)) / divisor
}
return b
}

line, col := 1, 2 // TODO: Why is this 2?
for si, bi := 0, 0; si < len(src) && bi < len(p.Blocks); {
b := p.Blocks[bi]
if b.StartLine == line && b.StartCol == col {
boundaries = append(boundaries, boundary(si, true, b.Count))
}
if b.EndLine == line && b.EndCol == col {
boundaries = append(boundaries, boundary(si, false, 0))
bi++
continue // Don't advance through src; maybe the next block starts here.
}
if src[si] == '\n' {
line++
col = 0
}
col++
si++
}
sort.Sort(boundariesByPos(boundaries))
return
}

type boundariesByPos []Boundary

func (b boundariesByPos) Len() int { return len(b) }
Expand Down

0 comments on commit f3475ed

Please sign in to comment.