Skip to content

Commit

Permalink
filters: accelerate text search
Browse files Browse the repository at this point in the history
  • Loading branch information
LinqLover committed Jun 19, 2024
1 parent 5bc9a27 commit db5869b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
filtering
filter: conversations
"Overridden for performance."

| partSearchers |
self isActive ifFalse: [^ conversations].

partSearchers := self partSearchers.

^ conversations select: [:conversation |
partSearchers allSatisfy: [:searcher |
(searcher matchesIn: conversation) talkIsEmpty not]]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ private
partTerms
"Split the current term into part terms that form a complex term together."

| patternFull patternMulti patternSingle patternTerm regexFull regexMulti regexSingle termStream |
| patternMulti patternSingle regexFull regexMulti regexSingle termStream |
(self usesRegex not and: [self hasComplexTerm]) ifFalse: [^ {self term}].

self term withBlanksTrimmed ifEmpty: [^ {self term}].
Expand All @@ -12,13 +12,16 @@ partTerms
self flag: #regexFamily.
patternSingle := '[^\s"]+'.
patternMulti := '"([^"\\]|\\["\\])+"'.
regexSingle := patternSingle asRegex.
regexMulti := patternMulti asRegex.
patternTerm := '(?%<=^|\s)(<1s>|<2s>)(?=\s|$)'
regexSingle := [patternSingle asRegex] once.
regexMulti := [patternMulti asRegex] once.
regexFull :=
[| patternTerm patternFull |
patternTerm := '(?%<=^|\s)(<1s>|<2s>)(?=\s|$)'
expandMacrosWith: patternSingle
with: patternMulti.
patternFull := '^(\s*(<1s>)\s*)*$' expandMacrosWith: patternTerm.
regexFull := patternFull asRegex.
patternFull := '^(\s*(<1s>)\s*)*$' expandMacrosWith: patternTerm.
patternFull asRegex]
once.

termStream := self term readStream.
(regexFull matchesStream: termStream) ifFalse: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"doMatchWildcard" : "ct 12/4/2021 23:45",
"doUseRegex" : "ct 6/17/2021 15:26",
"errors" : "ct 6/18/2021 00:33",
"filter:" : "ct 6/19/2024 18:10",
"fullyMatches:" : "ct 7/24/2021 00:12",
"fuzzyStrategies" : "ct 7/24/2021 00:57",
"hasComplexTerm" : "ct 7/24/2021 00:47",
Expand Down Expand Up @@ -51,7 +52,7 @@
"numberOfSurroundingLines" : "ct 7/24/2021 00:52",
"numberOfSurroundingLines:" : "ct 7/24/2021 00:52",
"partSearchers" : "ct 7/24/2021 00:59",
"partTerms" : "ct 7/24/2021 01:00",
"partTerms" : "ct 6/7/2024 17:02",
"postCopy" : "ct 6/11/2021 18:11",
"regexIntervalsIn:" : "ct 7/22/2021 19:40",
"removeRedundantLabelsFromMatches:" : "ct 1/5/2024 16:25",
Expand Down

0 comments on commit db5869b

Please sign in to comment.