diff options
author | Lukas Larsson <[email protected]> | 2017-10-12 15:55:04 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2017-11-20 09:57:46 +0100 |
commit | f1666d981aab4e4cf94b91dc097675fa0b056c97 (patch) | |
tree | 3a592f71441ba7a750d430b73c0a8d696c5c7978 /lib/stdlib/src/io_lib_pretty.erl | |
parent | a1c796e7f6b86b4b506492ae6354382c565278d1 (diff) | |
download | otp-f1666d981aab4e4cf94b91dc097675fa0b056c97.tar.gz otp-f1666d981aab4e4cf94b91dc097675fa0b056c97.tar.bz2 otp-f1666d981aab4e4cf94b91dc097675fa0b056c97.zip |
stdlib: Make io_lib and io_lib_pretty use maps iterator
Diffstat (limited to 'lib/stdlib/src/io_lib_pretty.erl')
-rw-r--r-- | lib/stdlib/src/io_lib_pretty.erl | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/stdlib/src/io_lib_pretty.erl b/lib/stdlib/src/io_lib_pretty.erl index 505613b80e..89e1931d2d 100644 --- a/lib/stdlib/src/io_lib_pretty.erl +++ b/lib/stdlib/src/io_lib_pretty.erl @@ -478,9 +478,19 @@ print_length(Term, _D, _RF, _Enc, _Str) -> print_length_map(_Map, 1, _RF, _Enc, _Str) -> {"#{...}", 6}; print_length_map(Map, D, RF, Enc, Str) when is_map(Map) -> - Pairs = print_length_map_pairs(erts_internal:maps_to_list(Map, D), D, RF, Enc, Str), + Pairs = print_length_map_pairs(limit_map(maps:iterator(Map), D, []), D, RF, Enc, Str), {{map, Pairs}, list_length(Pairs, 3)}. +limit_map(_I, 0, Acc) -> + Acc; +limit_map(I, D, Acc) -> + case maps:next(I) of + {K, V, NextI} -> + limit_map(NextI, D-1, [{K,V} | Acc]); + none -> + Acc + end. + print_length_map_pairs([], _D, _RF, _Enc, _Str) -> []; print_length_map_pairs(_Pairs, 1, _RF, _Enc, _Str) -> |