ソースを参照

ft:代码优化

master
SisMaker 4年前
コミット
9072c9c029
2個のファイルの変更12行の追加13行の削除
  1. +4
    -5
      src/eFmt.erl
  2. +8
    -8
      src/eFmtPretty.erl

+ 4
- 5
src/eFmt.erl ファイルの表示

@ -105,7 +105,7 @@ write(Term, Depth) ->
write(Term, Depth, IsPretty) ->
case IsPretty of
true ->
eFmtPretty:pPrint(Term, 1, 80, Depth);
eFmtPretty:pPrint(Term, 1, 120, Depth);
_ ->
writeTerm(Term, Depth, latin1)
end.
@ -118,8 +118,7 @@ write(Term, Depth, Encoding, CharsLimit) ->
CharsLimit < 0 ->
writeTerm(Term, Depth, Encoding);
true ->
RecDefFun = fun(_, _) -> no end,
If = eFmtPretty:pIntermediate(Term, Depth, CharsLimit, RecDefFun, Encoding, _Str = false),
If = eFmtPretty:pIntermediate(Term, Depth, CharsLimit, no_fun, Encoding, _Str = false),
eFmtPretty:pWrite(If)
end.
@ -537,9 +536,9 @@ print(Term, Depth, Width, _Adjust, Precision, _PadChar, Encoding, Strings, Chars
Width == none ->
if
Precision == none ->
eFmtPretty:print(Term, I + 1, 80, Depth, -1, CharsLimit, no_fun, Encoding, Strings);
eFmtPretty:print(Term, I + 1, 120, Depth, -1, CharsLimit, no_fun, Encoding, Strings);
true ->
eFmtPretty:print(Term, Precision, 80, Depth, -1, CharsLimit, no_fun, Encoding, Strings)
eFmtPretty:print(Term, Precision, 120, Depth, -1, CharsLimit, no_fun, Encoding, Strings)
end;
true ->
if

+ 8
- 8
src/eFmtPretty.erl ファイルの表示

@ -24,7 +24,7 @@
-spec pPrint(term()) -> io_lib:chars().
pPrint(Term) ->
print(Term, 1, 80, -1, -1, -1, no_fun, latin1, true).
print(Term, 1, 120, -1, -1, -1, no_fun, latin1, true).
%% print(Term, RecDefFun) -> [Chars]
%% print(Term, Depth, RecDefFun) -> [Chars]
@ -55,7 +55,7 @@ pPrint(Term) ->
pPrint(Term, Options) when is_list(Options) ->
Col = get_option(column, Options, 1),
Ll = get_option(line_length, Options, 80),
Ll = get_option(line_length, Options, 120),
D = get_option(depth, Options, -1),
M = get_option(line_max_chars, Options, -1),
T = get_option(chars_limit, Options, -1),
@ -69,7 +69,7 @@ pPrint(Term, RecDefFun) ->
-spec pPrint(term(), depth(), rec_print_fun()) -> chars().
pPrint(Term, Depth, RecDefFun) ->
pPrint(Term, 1, 80, Depth, RecDefFun).
pPrint(Term, 1, 120, Depth, RecDefFun).
-spec pPrint(term(), column(), line_length(), depth()) -> chars().
pPrint(Term, Col, Ll, D) ->
@ -91,7 +91,7 @@ pPrint(Term, Col, Ll, D, M, RecDefFun) ->
%% Used together with D to limit the output. It is possible that
%% more than T characters are returned.
%% Col = current column, default 1
%% Ll = line length/~p field width, default 80
%% Ll = line length/~p field width, default 120
%% M = CHAR_MAX (-1 if no max, 60 when printing from shell)
%%Term, Precision, Width, Depth, -1, CharsLimit, no_fun, Encoding, Strings
@ -423,14 +423,14 @@ write_tail(E, S) ->
-spec pIntermediate(term(), depth(), pos_integer(), rec_print_fun(),
encoding(), boolean()) -> intermediate_format().
pIntermediate(Term, D, T, RF, Enc, Str) when T > 0 ->
pIntermediate(Term, Depth, CharsLimit, RF, Enc, Str) ->
D0 = 1,
If = print_length(Term, D0, T, RF, Enc, Str),
If = print_length(Term, D0, CharsLimit, RF, Enc, Str),
case If of
{_, Len, Dots, _} when Dots =:= 0; Len > T; D =:= 1 ->
{_, Len, Dots, _} when Dots =:= 0; Len > CharsLimit; Depth =:= 1 ->
If;
_ ->
find_upper(If, Term, T, D0, 2, D, RF, Enc, Str)
find_upper(If, Term, CharsLimit, D0, 2, Depth, RF, Enc, Str)
end.
find_upper(Lower, Term, T, Dl, Dd, D, RF, Enc, Str) ->

読み込み中…
キャンセル
保存