Add more performance and memory optimizations

This commit is contained in:
Zachary Yedidia
2017-03-24 14:11:21 -04:00
parent 87f54be13a
commit d413562145
6 changed files with 84 additions and 73 deletions

View File

@@ -2,11 +2,11 @@ package highlight
func DetectFiletype(defs []*Def, filename string, firstLine []byte) *Def {
for _, d := range defs {
if isMatch, _ := d.ftdetect[0].MatchString(filename); isMatch {
if d.ftdetect[0].MatchString(filename) {
return d
}
if len(d.ftdetect) > 1 {
if isMatch, _ := d.ftdetect[1].MatchString(string(firstLine)); isMatch {
if d.ftdetect[1].MatchString(string(firstLine)) {
return d
}
}