summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriilyak <iilyak@ca.ibm.com>2017-06-07 10:54:43 -0700
committerGitHub <noreply@github.com>2017-06-07 10:54:43 -0700
commit2062aff2c78f93ce935658cfded852bca7b6b300 (patch)
tree727fba5d41a229f01e2ccab2949cae803c48087e
parent93707fc08ad42792719a319af233d422a5f1aebd (diff)
parentdb7e9efdf8e74431af8816d4fa3965ff8cde5a7c (diff)
downloadcouchdb-2062aff2c78f93ce935658cfded852bca7b6b300.tar.gz
Merge pull request #586 from cloudant/avoid_use_of_length
Avoid using length to detect non empty list
-rw-r--r--src/mango/src/mango_selector.erl6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/mango/src/mango_selector.erl b/src/mango/src/mango_selector.erl
index 13e7d883b..bcf347201 100644
--- a/src/mango/src/mango_selector.erl
+++ b/src/mango/src/mango_selector.erl
@@ -186,7 +186,7 @@ norm_ops({[{Field, Cond}]}) ->
{[{Field, norm_ops(Cond)}]};
% An implicit $and
-norm_ops({Props}) when length(Props) > 1 ->
+norm_ops({[_, _ | _] = Props}) ->
{[{<<"$and">>, [norm_ops({[P]}) || P <- Props]}]};
% A bare value condition means equality
@@ -461,7 +461,7 @@ match({[{<<"$elemMatch">>, _Arg}]}, _Value, _Cmp) ->
% Matches when all elements in values match the
% sub-selector Arg.
-match({[{<<"$allMatch">>, Arg}]}, Values, Cmp) when is_list(Values), length(Values) > 0 ->
+match({[{<<"$allMatch">>, Arg}]}, [_ | _] = Values, Cmp) ->
try
lists:foreach(fun(V) ->
case match(Arg, V, Cmp) of
@@ -564,5 +564,5 @@ match({[{Field, Cond}]}, Value, Cmp) ->
match(Cond, SubValue, Cmp)
end;
-match({Props} = Sel, _Value, _Cmp) when length(Props) > 1 ->
+match({[_, _ | _] = _Props} = Sel, _Value, _Cmp) ->
erlang:error({unnormalized_selector, Sel}).