mirror of
https://github.com/github/semantic.git
synced 2024-11-24 00:42:33 +03:00
Compute the substring once and only once.
This commit is contained in:
parent
3e22121d66
commit
718399c7d9
@ -64,7 +64,7 @@ replaceLeavesWithWordBranches :: String -> Term String Info -> Term String Info
|
||||
replaceLeavesWithWordBranches source term = replaceIn source 0 term
|
||||
where
|
||||
replaceIn source startIndex (info@(Info range lineRange categories) :< syntax) | range <- offsetRange (negate startIndex) range = info :< case syntax of
|
||||
Leaf _ | ranges <- rangesOfWordsFrom (start range) (substring range source), length ranges > 1 -> Indexed $ makeLeaf (substring range source) startIndex lineRange categories <$> ranges
|
||||
Leaf _ | substring <- substring range source, ranges <- rangesOfWordsFrom (start range) substring, length ranges > 1 -> Indexed $ makeLeaf substring startIndex lineRange categories <$> ranges
|
||||
Indexed i -> Indexed $ replaceIn (substring range source) (start range) <$> i
|
||||
Fixed f -> Fixed $ replaceIn (substring range source) (start range) <$> f
|
||||
Keyed k -> Keyed $ replaceIn (substring range source) (start range) <$> k
|
||||
|
Loading…
Reference in New Issue
Block a user