Skip to content

Commit

Permalink
Added check to avoid needless re-searching
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenldl committed May 16, 2023
1 parent f994d63 commit d25d13c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.8.5

- Added check to skip re-searching if search phrase is equivalent to the previous one

## 0.8.4

- Index data structure optimization
Expand Down
22 changes: 13 additions & 9 deletions src/document_store.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,19 @@ let min_binding (t : t) =
)

let update_search_phrase search_phrase (t : t) : t =
{ t with
search_phrase;
search_results =
String_option_map.mapi (fun path _ ->
let doc = String_option_map.find path t.documents in
(Index.search search_phrase doc.index)
)
t.search_results;
}
if Search_phrase.equal search_phrase t.search_phrase then (
t
) else (
{ t with
search_phrase;
search_results =
String_option_map.mapi (fun path _ ->
let doc = String_option_map.find path t.documents in
(Index.search search_phrase doc.index)
)
t.search_results;
}
)

let add_document (doc : Document.t) (t : t) : t =
{ t with
Expand Down
2 changes: 1 addition & 1 deletion src/version_string.ml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
let s = "0.8.4"
let s = "0.8.5"

0 comments on commit d25d13c

Please sign in to comment.