You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by gi...@git.apache.org on 2017/04/06 18:09:16 UTC

[GitHub] iilyak commented on a change in pull request #471: Use efficient set storage for field names

iilyak commented on a change in pull request #471: Use efficient set storage for field names
URL: https://github.com/apache/couchdb/pull/471#discussion_r110229614
 
 

 ##########
 File path: src/mango/src/mango_native_proc.erl
 ##########
 @@ -257,15 +257,10 @@ add_default_text_field([_ | Rest], Acc) ->
 
 
 %% index of all field names
-get_field_names([], FAcc) ->
-    FAcc;
-get_field_names([{Name, _Type, _Value} | Rest], FAcc) ->
-    case lists:member([<<"$fieldnames">>, Name, []], FAcc) of
-        true ->
-            get_field_names(Rest, FAcc);
-        false ->
-            get_field_names(Rest, [[<<"$fieldnames">>, Name, []] | FAcc])
-    end.
+get_field_names(Fields) ->
+    GBFieldSet = gb_sets:from_list(Fields),
 
 Review comment:
   `Fields` is a list of size 3 tuples of following structure `{FieldName, Type, Value}`.  We would want to ignore Value. Something like this would do it.
   ```
   Set = lists:foldl(
       fun({Name, _, _}, Set) -> 
            gb_sets:add([<<"$fieldnames">>, Name, []], Set) 
       end, gb_sets:new(), Fields),
   gb_sets:to_list(Set).
   ```
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services