Repository: couchdb-mango
Updated Branches:
  refs/heads/2787-merge-repos 6100a0b68 -> f12076f24


Use module_loaded instead of module_info

COUCHDB-2787


Project: http://git-wip-us.apache.org/repos/asf/couchdb-mango/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-mango/commit/874e8d2a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-mango/tree/874e8d2a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-mango/diff/874e8d2a

Branch: refs/heads/2787-merge-repos
Commit: 874e8d2a74f83e19aedfd0acb1e562f918844c99
Parents: 6100a0b
Author: Tony Sun <tony....@cloudant.com>
Authored: Thu Sep 3 13:01:33 2015 -0700
Committer: Tony Sun <tony....@cloudant.com>
Committed: Thu Sep 3 13:01:33 2015 -0700

----------------------------------------------------------------------
 src/mango_cursor.erl |  2 +-
 src/mango_idx.erl    |  8 ++++----
 src/mango_util.erl   | 17 +----------------
 3 files changed, 6 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/874e8d2a/src/mango_cursor.erl
----------------------------------------------------------------------
diff --git a/src/mango_cursor.erl b/src/mango_cursor.erl
index d73761e..6cb7fee 100644
--- a/src/mango_cursor.erl
+++ b/src/mango_cursor.erl
@@ -123,7 +123,7 @@ group_indexes_by_type(Indexes) ->
     % used to service this query. This is so that we
     % don't suddenly switch indexes for existing client
     % queries.
-    CursorModules = case mango_util:module_exists(dreyfus_index) of
+    CursorModules = case module_loaded(dreyfus_index) of
         true ->
             [mango_cursor_view, mango_cursor_text];
         false ->

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/874e8d2a/src/mango_idx.erl
----------------------------------------------------------------------
diff --git a/src/mango_idx.erl b/src/mango_idx.erl
index 6f73af1..56b7fc2 100644
--- a/src/mango_idx.erl
+++ b/src/mango_idx.erl
@@ -166,7 +166,7 @@ from_ddoc(Db, {Props}) ->
         _ ->
             ?MANGO_ERROR(invalid_query_ddoc_language)
     end,
-    IdxMods = case mango_util:module_exists(dreyfus_index) of
+    IdxMods = case module_loaded(dreyfus_index) of
         true ->
             [mango_idx_view, mango_idx_text];
         false ->
@@ -247,7 +247,7 @@ cursor_mod(#idx{type = <<"json">>}) ->
 cursor_mod(#idx{def = all_docs, type= <<"special">>}) ->
     mango_cursor_view;
 cursor_mod(#idx{type = <<"text">>}) ->
-    case mango_util:module_exists(dreyfus_index) of
+    case module_loaded(dreyfus_index) of
         true ->
             mango_cursor_text;
         false ->
@@ -260,7 +260,7 @@ idx_mod(#idx{type = <<"json">>}) ->
 idx_mod(#idx{type = <<"special">>}) ->
     mango_idx_special;
 idx_mod(#idx{type = <<"text">>}) ->
-    case mango_util:module_exists(dreyfus_index) of
+    case module_loaded(dreyfus_index) of
         true ->
             mango_idx_text;
         false ->
@@ -288,7 +288,7 @@ get_idx_def(Opts) ->
 get_idx_type(Opts) ->
     case proplists:get_value(type, Opts) of
         <<"json">> -> <<"json">>;
-        <<"text">> -> case mango_util:module_exists(dreyfus_index) of
+        <<"text">> -> case module_loaded(dreyfus_index) of
             true ->
                 <<"text">>;
             false ->

http://git-wip-us.apache.org/repos/asf/couchdb-mango/blob/874e8d2a/src/mango_util.erl
----------------------------------------------------------------------
diff --git a/src/mango_util.erl b/src/mango_util.erl
index 553535d..c3513dc 100644
--- a/src/mango_util.erl
+++ b/src/mango_util.erl
@@ -42,9 +42,7 @@
 
     parse_field/1,
 
-    cached_re/2,
-
-    module_exists/1
+    cached_re/2
 ]).
 
 
@@ -397,19 +395,6 @@ check_non_empty(Field, Parts) ->
             Parts
     end.
 
-module_exists(Module) ->
-    case is_atom(Module) of
-        true ->
-            try Module:module_info() of
-                _InfoList ->
-                    true
-            catch
-                _:_ ->
-                    false
-            end;
-        false ->
-            false
-    end.
 
 -ifdef(TEST).
 -include_lib("eunit/include/eunit.hrl").

Reply via email to