code: func (p *Profile) FilterSamplesByName(focus, ignore, hide, show *regexp.Regexp) (fm, im, hm, hnm bool) {
  	focusOrIgnore := make(map[uint64]bool)
  	hidden := make(map[uint64]bool)
  	for _, l := range p.Location {
  		if ignore != nil && l.matchesName(ignore) {
  			im = true
  			focusOrIgnore[l.ID] = false
  		} else if focus == nil || l.matchesName(focus) {
  			fm = true
  			focusOrIgnore[l.ID] = true
  		}
  
  		if hide != nil && l.matchesName(hide) {
  			hm = true
  			l.Line = l.unmatchedLines(hide)
  			if len(l.Line) == 0 {
  				hidden[l.ID] = true
  			}
  		}
  		if show != nil {
  			l.Line = l.matchedLines(show)
  			if len(l.Line) == 0 {
  				hidden[l.ID] = true
  			} else {
  				hnm = true
  			}
  		}
  	}
  
  	s := make([]*Sample, 0, len(p.Sample))
  	for _, sample := range p.Sample {
  		if focusedAndNotIgnored(sample.Location, focusOrIgnore) {
  			if len(hidden) > 0 {
  				var locs []*Location
  				for _, loc := range sample.Location {
  					if !hidden[loc.ID] {
  						locs = append(locs, loc)
  					}
  				}
  				if len(locs) == 0 {
  					// Remove sample with no locations (by not adding it to s).
  					continue
  				}
  				sample.Location = locs
  			}
  			s = append(s, sample)
  		}
  	}
  	p.Sample = s
  
  	return
  }
docs: // FilterSamplesByName filters the samples in a profile and only keeps
  // samples where at least one frame matches focus but none match ignore.
  // Returns true is the corresponding regexp matched at least one sample.