You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by to...@apache.org on 2015/09/10 02:34:23 UTC

[21/26] couchdb-mango git commit: Use module_loaded instead of module_info

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/master
Commit: 874e8d2a74f83e19aedfd0acb1e562f918844c99
Parents: 6100a0b
Author: Tony Sun <to...@cloudant.com>
Authored: Thu Sep 3 13:01:33 2015 -0700
Committer: Tony Sun <to...@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").