mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
be stricter about boolean optimization
This commit is contained in:
parent
8a7ca9dbcb
commit
627dfbefdb
1 changed files with 10 additions and 4 deletions
|
@ -274,19 +274,25 @@ defmodule Search.Parser do
|
|||
end
|
||||
|
||||
# Flattens the child of a disjunction or conjunction to improve performance.
|
||||
defp flatten_disjunction_child(this_child, %{bool: %{should: next_child}}),
|
||||
defp flatten_disjunction_child(this_child, %{bool: %{should: next_child}} = child)
|
||||
when child == %{bool: %{should: next_child}} and is_list(next_child),
|
||||
do: %{bool: %{should: [this_child | next_child]}}
|
||||
|
||||
defp flatten_disjunction_child(this_child, next_child),
|
||||
do: %{bool: %{should: [this_child, next_child]}}
|
||||
|
||||
defp flatten_conjunction_child(this_child, %{bool: %{must: next_child}}),
|
||||
defp flatten_conjunction_child(this_child, %{bool: %{must: next_child}} = child)
|
||||
when child == %{bool: %{must: next_child}} and is_list(next_child),
|
||||
do: %{bool: %{must: [this_child | next_child]}}
|
||||
|
||||
defp flatten_conjunction_child(this_child, next_child),
|
||||
do: %{bool: %{must: [this_child, next_child]}}
|
||||
|
||||
# Flattens the child of a negation to eliminate double negation.
|
||||
defp flatten_negation_child(%{bool: %{must_not: next_child}}),
|
||||
defp flatten_negation_child(%{bool: %{must_not: next_child}} = child)
|
||||
when child == %{bool: %{must_not: next_child}} and is_map(next_child),
|
||||
do: next_child
|
||||
|
||||
defp flatten_negation_child(next_child),
|
||||
do: %{bool: %{must_not: next_child}}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue