소스 검색

Use dict() instead of proplist() for shared env

pull/3/head
Tuncer Ayaz 13 년 전
부모
커밋
b2fdce8879
1개의 변경된 파일6개의 추가작업 그리고 9개의 파일을 삭제
  1. +6
    -9
      src/rebar_config.erl

+ 6
- 9
src/rebar_config.erl 파일 보기

@ -38,10 +38,7 @@
-record(config, { dir :: file:filename(),
opts = [] :: list(),
envs = [] :: list({module(), env()}) }).
-type env() :: [env_var()].
-type env_var() :: {string(), string()}.
envs = new_env() :: dict() }).
%% Types that can be used from other modules -- alphabetically ordered.
-export_type([config/0]).
@ -149,14 +146,11 @@ consult_file(File) ->
set_env(Config, Mod, Env) ->
OldEnvs = Config#config.envs,
NewEnvs = case lists:keymember(Mod, 1, OldEnvs) of
true -> lists:keyreplace(Mod, 1, OldEnvs, {Mod, Env});
false -> [{Mod,Env}|OldEnvs]
end,
NewEnvs = dict:store(Mod, Env, OldEnvs),
Config#config{envs=NewEnvs}.
get_env(Config, Mod) ->
proplists:get_value(Mod, Config#config.envs, []).
dict:fetch(Mod, Config#config.envs).
%% ===================================================================
%% Internal functions
@ -193,3 +187,6 @@ local_opts([local | _Rest], Acc) ->
lists:reverse(Acc);
local_opts([Item | Rest], Acc) ->
local_opts(Rest, [Item | Acc]).
new_env() ->
dict:new().

불러오는 중...
취소
저장