Skip to content

Commit 9b5509f

Browse files
committed
fix: skip parsing document if content is the same
1 parent b27f334 commit 9b5509f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

errgoengine.go

+5
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ func ParseFiles(contextData *ContextData, defaultLanguage *Language, files fs.Re
200200
// check if document already exists
201201
existingDoc, docExists := contextData.Documents[path]
202202

203+
if docExists && existingDoc.BytesContentEquals(contents) {
204+
// do not parse if content is the same
205+
continue
206+
}
207+
203208
// check matched languages
204209
selectedLanguage := defaultLanguage
205210
if docExists {

source.go

+8
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,14 @@ type Document struct {
504504
Tree *sitter.Tree
505505
}
506506

507+
func (doc *Document) StringContentEquals(str string) bool {
508+
return doc.Contents == str
509+
}
510+
511+
func (doc *Document) BytesContentEquals(cnt []byte) bool {
512+
return doc.Contents == string(cnt)
513+
}
514+
507515
func (doc *Document) RootNode() SyntaxNode {
508516
return WrapNode(doc, doc.Tree.RootNode())
509517
}

0 commit comments

Comments
 (0)