Skip to content

Commit ca8b61e

Browse files
committed
Remove support for old OTP versions
1 parent ab2da38 commit ca8b61e

File tree

4 files changed

+3
-57
lines changed

4 files changed

+3
-57
lines changed

include/msgpack.hrl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,6 @@
8484
original_list = [] :: msgpack_list_options()
8585
}).
8686

87-
-ifdef(without_map).
88-
89-
-define(OPTION, #options_v2).
90-
-type msgpack_option() :: #options_v2{}.
91-
92-
-else.
93-
9487
-record(options_v3, {
9588
interface = ?DEFAULT_MAP_FORMAT :: format_type(),
9689
map_unpack_fun = ?DEFAULT_MAP_UNPACKER_FUN :: msgpack_map_unpacker(),
@@ -104,6 +97,3 @@
10497

10598
-define(OPTION, #options_v3).
10699
-type msgpack_option() :: #options_v3{}.
107-
108-
-endif.
109-

rebar.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{require_otp_vsn, "R15|R16|17|18"}.
1+
{require_otp_vsn, "17|18"}.
22

33
{erl_opts, [fail_on_warning, debug_info, warn_untyped_record]}.
44
{xref_checks, [undefined_function_calls]}.

src/msgpack_packer.erl

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -85,33 +85,6 @@ pack(List, Opt) when is_list(List) ->
8585
pack(Other, Opt) ->
8686
handle_ext(Other, Opt).
8787

88-
-ifdef(without_map).
89-
90-
%% TODO: maybe we don't need this inside ifdef
91-
%% as to use ?OPTION{enable_str=boolean()}
92-
handle_binary(Bin, Opt) ->
93-
case Opt of
94-
#options_v2{enable_str=true} = Opt -> pack_raw2(Bin);
95-
#options_v2{enable_str=false} = Opt -> pack_raw(Bin);
96-
#options_v1{} = Opt -> pack_raw(Bin)
97-
end.
98-
99-
%% Packing ext type with user defined packer function
100-
handle_ext(Any, _Opt = ?OPTION{ext_packer=Packer,
101-
original_list=Orig,
102-
interface=Interface})
103-
when is_function(Packer) andalso Interface =/= map ->
104-
105-
case pack_ext(Any, Packer, Orig) of
106-
{ok, Binary} -> Binary;
107-
{error, E} -> throw({error, E})
108-
end;
109-
110-
handle_ext(Other, _) ->
111-
throw({badarg, Other}).
112-
113-
-else.
114-
11588
handle_binary(Bin, Opt) ->
11689
case Opt of
11790
#options_v3{enable_str=true} = Opt -> pack_raw2(Bin);
@@ -137,8 +110,6 @@ handle_ext(Any, _Opt = ?OPTION{ext_packer=Packer,
137110
handle_ext(Other, _) ->
138111
throw({badarg, Other}).
139112

140-
-endif.
141-
142113
-spec pack_int(integer()) -> binary().
143114
%% negative fixnum
144115
pack_int(N) when N >= -32->

src/msgpack_unpacker.erl

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@
2424
-include_lib("eunit/include/eunit.hrl").
2525

2626

27-
-ifndef(without_map).
28-
-export([unpack_map/3]).
29-
-endif.
30-
31-
-export([unpack_map_jiffy/3, unpack_map_jsx/3]).
27+
-export([unpack_map/3, unpack_map_jiffy/3, unpack_map_jsx/3]).
3228

3329
%% unpack them all
3430
-spec unpack_stream(Bin::binary(), msgpack_option()) -> {msgpack:object(), binary()} | no_return().
@@ -175,36 +171,25 @@ unpack_array(Bin, Len, Acc, Opt) ->
175171
{Term, Rest} = unpack_stream(Bin, Opt),
176172
unpack_array(Rest, Len-1, [Term|Acc], Opt).
177173

178-
-ifdef(without_map).
179-
map_unpacker(jiffy) ->
180-
fun ?MODULE:unpack_map_jiffy/3;
181-
map_unpacker(jsx) ->
182-
fun ?MODULE:unpack_map_jsx/3.
183-
-else.
184174
map_unpacker(map) ->
185175
fun ?MODULE:unpack_map/3;
186176
map_unpacker(jiffy) ->
187177
fun ?MODULE:unpack_map_jiffy/3;
188178
map_unpacker(jsx) ->
189179
fun ?MODULE:unpack_map_jsx/3.
190-
-endif.
191-
192-
193180

194-
-ifndef(without_map).
195181
-spec unpack_map(binary(), non_neg_integer(), msgpack_option()) ->
196182
{map(), binary()} | no_return().
197183
unpack_map(Bin, Len, Opt) ->
184+
%% TODO: optimize with unpack_map/4
198185
{Map, Rest} = unpack_map_as_proplist(Bin, Len, [], Opt),
199186
{maps:from_list(Map), Rest}.
200-
%% unpack_map(Bin, Len, #{}, Opt).
201187

202188
%% unpack_map(Bin, Len, Acc, _) -> {Acc, Bin};
203189
%% unpack_map(Bin, Len, Acc, Opt) ->
204190
%% {Key, Rest} = unpack_stream(Bin, Opt),
205191
%% {Value, Rest2} = unpack_stream(Rest, Opt),
206192
%% unpack_map(Rest2, Len-1, maps:put(Key, Value, Acc), Opt).
207-
-endif.
208193

209194
%% Users SHOULD NOT send too long list: this uses lists:reverse/1
210195
-spec unpack_map_jiffy(binary(), non_neg_integer(), msgpack_option()) ->

0 commit comments

Comments
 (0)