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.
23 lines
292 B
Go
Executable File
23 lines
292 B
Go
Executable File
package buffer
|
|
|
|
type Syntax uint8
|
|
|
|
const (
|
|
Default Syntax = iota
|
|
Keyword
|
|
String
|
|
Special
|
|
Type
|
|
Number
|
|
Builtin
|
|
Comment
|
|
DocComment
|
|
)
|
|
|
|
type Language struct {
|
|
Name string
|
|
Filetypes []string // .go, .c, etc.
|
|
Rules map[*RegexpRegion]Syntax
|
|
// TODO: add other language details
|
|
}
|