// decide whether the pos
// at the specified index is a boundary or not. It's just not worth
// emitting inline code for this logic.
191531
func (r *runner) isBoundary(index, startpos, endpos int) bool {
	return (index > startpos && syntax.IsWordChar(r.runtext[index-1])) !=
		(index < endpos && syntax.IsWordChar(r.runtext[index]))
}
1058660
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 || line > b.EndLine {
			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
}
1258602
func (p Point) IsInf() bool {
	return math.IsInf(p.x, 0) || math.IsInf(p.y, 0)
}
592006
func assertPos(skip int) string {
	if !IncludeFilePosition {
		return ""
	}
	res := ""
	for i := 0; i < 5; i++ {
		pc, file, line, ok := runtime.Caller(skip + 2)
		if !ok {
			return ""
		}
		res = fmt.Sprintf("%s:%d: ", path.Base(file), line) + res

		if isTestFuncName(runtime.FuncForPC(pc).Name()) {
			break
		}
		skip++
	}
	return "\n" + res
}
449615
func (r *RuneBuffer) MoveToLineEnd() {
	for i := r.idx; i < len(r.buf)-1; i++ {
		if r.buf[i] == '\n' {
			r.idx = i
			return
		}
	}
	r.idx = len(r.buf)
}
325892
func (l *State) AbsIndex(index int) int {
	if index > 0 || isPseudoIndex(index) {
		return index
	}
	return l.top - l.callInfo.function + index
}
361257
func (b *BmPrefix) IsMatch(text []rune, index, beglimit, endlimit int) bool {
	if !b.rightToLeft {
		if index < beglimit || endlimit-index < len(b.pattern) {
			return false
		}

		return b.matchPattern(text, index)
	} else {
		if index > endlimit || index-beglimit < len(b.pattern) {
			return false
		}

		return b.matchPattern(text, index-len(b.pattern))
	}
}
923309
func (a IndexRules) Cutoffs(now time.Time) []int64 {
	out := make([]int64, len(a.Rules)+1)
	for i := 0; i <= len(a.Rules); i++ {
		var rule IndexRule
		if i < len(a.Rules) {
			rule = a.Rules[i]
		} else {
			rule = a.Default
		}
		if rule.MaxStale == 0 {
			out[i] = 0
		} else {
			out[i] = int64(now.Add(rule.MaxStale * -1).Unix())
		}
	}
	return out
}
194453
func (d *Context) IsBoundFunction(index int) bool {
	return int(C.duk_is_bound_function(d.duk_context, C.duk_idx_t(index))) == 1
}
867056
func (r *importReader) pos() {
	if r.int64() != deltaNewFile {
	} else if l := r.int64(); l == -1 {
	} else {
		r.string()
	}
}
426298
func (l *Loop) bruteForceContainsPoint(p Point) bool {
	origin := OriginPoint()
	inside := l.originInside
	crosser := NewChainEdgeCrosser(origin, p, l.Vertex(0))
	for i := 1; i <= len(l.vertices); i++ { // add vertex 0 twice
		inside = inside != crosser.EdgeOrVertexChainCrossing(l.Vertex(i))
	}
	return inside
}
1144045
func edgeIntersectsRect(a, b r2.Point, r r2.Rect) bool {
	// First check whether the bounds of a Rect around AB intersects the given rect.
	if !r.Intersects(r2.RectFromPoints(a, b)) {
		return false
	}

	// Otherwise AB intersects the rect if and only if all four vertices of rect
	// do not lie on the same side of the extended line AB. We test this by finding
	// the two vertices of rect with minimum and maximum projections onto the normal
	// of AB, and computing their dot products with the edge normal.
	n := b.Sub(a).Ortho()

	i := 0
	if n.X >= 0 {
		i = 1
	}
	j := 0
	if n.Y >= 0 {
		j = 1
	}

	max := n.Dot(r.VertexIJ(i, j).Sub(a))
	min := n.Dot(r.VertexIJ(1-i, 1-j).Sub(a))

	return (max >= 0) && (min <= 0)
}
426403
func (d *Document) findLineStartIndex(index int) (pos int, lineStartIndex int) {
	indexes := d.lineStartIndexes()
	pos = bisect.Right(indexes, index) - 1
	lineStartIndex = indexes[pos]
	return
}
169770
func (l *Lexer) IsEnd() bool {
	//u.Infof("isEnd? %v:%v", l.pos, len(l.input))
	if l.pos >= len(l.input) {
		return true
	}
	// if l.Peek() == ';' {
	// 	return true
	// }
	return false
}
908864
func IsValidExpression(expr string) bool {
	_, err := parseExpression(expr)
	return err == nil
}
1099267
func (s *Segment) IsFull() bool {
	s.Lock()
	defer s.Unlock()
	return s.Position >= s.maxBytes
}
251016
func CheckType(l *State, index int, t Type) {
	if l.TypeOf(index) != t {
		tagError(l, index, t)
	}
}