TextEdit & Highlighting: performance improvements & changes to architecture

I ran pprof to find what was causing stuttering, and found it to be the
getTabCountInLineAtCol function in TextEdit, because it was iterating
many bytes of the buffer, for each rune rendered. Replaced it with a more
optimal system. Also changed the architecture of the highlighting system
to use a single RegexpRange structure for all regular expressions. This
allows for optimizations and multiline matches in the future.
This commit is contained in:
Luke I. Wilson
2021-04-01 12:05:17 -05:00
parent 37589144b5
commit f829b37d0c
7 changed files with 221 additions and 55 deletions

View File

@ -1,7 +1,5 @@
package buffer
import "regexp"
type Syntax uint8
const (
@ -19,6 +17,6 @@ const (
type Language struct {
Name string
Filetypes []string // .go, .c, etc.
Rules map[*regexp.Regexp]Syntax
Rules map[*RegexpRegion]Syntax
// TODO: add other language details
}