aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2014-02-24 16:15:52 +0100
committerHenrik Nord <[email protected]>2014-02-24 16:15:52 +0100
commit4203d5c2acb4e807835b85a568a3e1dff21c930a (patch)
treeab91b7f923bcebc73946f1a54426d9d9618aa81e /lib
parente4b6877c43e7fdddc947e61bfcfb7f93aab35a7a (diff)
parented19b2bdaa89e6f6ca03211a9fb21457e92e64ea (diff)
downloadotp-4203d5c2acb4e807835b85a568a3e1dff21c930a.tar.gz
otp-4203d5c2acb4e807835b85a568a3e1dff21c930a.tar.bz2
otp-4203d5c2acb4e807835b85a568a3e1dff21c930a.zip
Merge branch 'Vagabond/adt-faster-io_lib_pretty/OTP-11752'
* Vagabond/adt-faster-io_lib_pretty/OTP-11752: Use lists:keyfind in io_lib_pretty as it is faster
Diffstat (limited to 'lib')
-rw-r--r--lib/stdlib/src/io_lib_pretty.erl21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/stdlib/src/io_lib_pretty.erl b/lib/stdlib/src/io_lib_pretty.erl
index 9005fede4d..4057abd8d5 100644
--- a/lib/stdlib/src/io_lib_pretty.erl
+++ b/lib/stdlib/src/io_lib_pretty.erl
@@ -66,13 +66,13 @@ print(Term) ->
(term(), options()) -> chars().
print(Term, Options) when is_list(Options) ->
- Col = proplists:get_value(column, Options, 1),
- Ll = proplists:get_value(line_length, Options, 80),
- D = proplists:get_value(depth, Options, -1),
- M = proplists:get_value(max_chars, Options, -1),
- RecDefFun = proplists:get_value(record_print_fun, Options, no_fun),
- Encoding = proplists:get_value(encoding, Options, epp:default_encoding()),
- Strings = proplists:get_value(strings, Options, true),
+ Col = get_option(column, Options, 1),
+ Ll = get_option(line_length, Options, 80),
+ D = get_option(depth, Options, -1),
+ M = get_option(max_chars, Options, -1),
+ RecDefFun = get_option(record_print_fun, Options, no_fun),
+ Encoding = get_option(encoding, Options, epp:default_encoding()),
+ Strings = get_option(strings, Options, true),
print(Term, Col, Ll, D, M, RecDefFun, Encoding, Strings);
print(Term, RecDefFun) ->
print(Term, -1, RecDefFun).
@@ -761,3 +761,10 @@ chars(C, N) when (N band 1) =:= 0 ->
chars(C, N) ->
S = chars(C, N bsr 1),
[C, S | S].
+
+get_option(Key, TupleList, Default) ->
+ case lists:keyfind(Key, 1, TupleList) of
+ false -> Default;
+ {Key, Value} -> Value;
+ _ -> Default
+ end.