From 70590d5e28b4c767ea77306796ccae5f733d7d0c Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Fri, 25 Mar 2016 21:21:10 -0400 Subject: [PATCH] Small optimization --- src/highlighter.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/highlighter.go b/src/highlighter.go index 607661ee..73f3dde1 100644 --- a/src/highlighter.go +++ b/src/highlighter.go @@ -249,7 +249,7 @@ func Match(v *View) SyntaxMatches { value[0] += startNum value[1] += startNum for i := value[0]; i < value[1]; i++ { - colNum, lineNum := GetPos(i, buf) + colNum, lineNum := GetPos(startNum, totalStart, i, buf) if lineNum == -1 || colNum == -1 { continue } @@ -283,9 +283,9 @@ func Match(v *View) SyntaxMatches { } // GetPos returns an x, y position given a character location in the buffer -func GetPos(loc int, buf *Buffer) (int, int) { - charNum := 0 - x, y := 0, 0 +func GetPos(startLoc, startLine, loc int, buf *Buffer) (int, int) { + charNum := startLoc + x, y := 0, startLine for i, line := range buf.lines { if charNum+Count(line) > loc {