Commits

Anonymous committed b17eddd

patch from Kostis Sagonas, obtained by using tidier, a tool that tidies Erlang code

Comments (0)

Files changed (6)

src/mochijson.erl

 equiv_list([], []) ->
     true;
 equiv_list([V1 | L1], [V2 | L2]) ->
-    case equiv(V1, V2) of
-        true ->
-            equiv_list(L1, L2);
-        false ->
-            false
-    end.
+    equiv(V1, V2) andalso equiv_list(L1, L2).
 
 test_all() ->
     test_issue33(),

src/mochijson2.erl

 equiv_list([], []) ->
     true;
 equiv_list([V1 | L1], [V2 | L2]) ->
-    case equiv(V1, V2) of
-        true ->
-            equiv_list(L1, L2);
-        false ->
-            false
-    end.
+    equiv(V1, V2) andalso equiv_list(L1, L2).
 
 test_all() ->
     [1199344435545.0, 1] = decode(<<"[1199344435545.0,1]">>),

src/mochiweb_multipart.erl

     Boundary = iolist_to_binary(
                  get_boundary(Req:get_header_value("content-type"))),
     Prefix = <<"\r\n--", Boundary/binary>>,
-    BS = size(Boundary),
+    BS = byte_size(Boundary),
     Chunk = read_chunk(Req, Length),
-    Length1 = Length - size(Chunk),
+    Length1 = Length - byte_size(Chunk),
     <<"--", Boundary:BS/binary, "\r\n", Rest/binary>> = Chunk,
     feed_mp(headers, flash_multipart_hack(#mp{boundary=Prefix,
                                               length=Length1,
 read_more(State=#mp{length=Length, buffer=Buffer, req=Req}) ->
     Data = read_chunk(Req, Length),
     Buffer1 = <<Buffer/binary, Data/binary>>,
-    flash_multipart_hack(State#mp{length=Length - size(Data),
+    flash_multipart_hack(State#mp{length=Length - byte_size(Data),
                                   buffer=Buffer1}).
 
 flash_multipart_hack(State=#mp{length=0, buffer=Buffer, boundary=Prefix}) ->
               eof],
     TestCallback = fun (Next) -> test_callback(Next, Expect) end,
     ServerFun = fun (Socket) ->
-                        case gen_tcp:send(Socket, BinContent) of
-                            ok ->
-                                exit(normal)
-                        end
+                        ok = gen_tcp:send(Socket, BinContent),
+			exit(normal)
                 end,
     ClientFun = fun (Socket) ->
                         Req = fake_request(Socket, ContentType,
-                                           size(BinContent)),
+                                           byte_size(BinContent)),
                         Res = parse_multipart_request(Req, TestCallback),
                         {0, <<>>, ok} = Res,
                         ok
               eof],
     TestCallback = fun (Next) -> test_callback(Next, Expect) end,
     ServerFun = fun (Socket) ->
-                        case gen_tcp:send(Socket, BinContent) of
-                            ok ->
-                                exit(normal)
-                        end
+                        ok = gen_tcp:send(Socket, BinContent),
+			exit(normal)
                 end,
     ClientFun = fun (Socket) ->
                         Req = fake_request(Socket, ContentType,
-                                           size(BinContent)),
+                                           byte_size(BinContent)),
                         Res = parse_multipart_request(Req, TestCallback),
                         {0, <<>>, ok} = Res,
                         ok
                  ""], "\r\n"),
     BinContent = iolist_to_binary(Content),
     ServerFun = fun (Socket) ->
-                        case gen_tcp:send(Socket, BinContent) of
-                            ok ->
-                                exit(normal)
-                        end
+                        ok = gen_tcp:send(Socket, BinContent),
+			exit(normal)
                 end,
     ClientFun = fun (Socket) ->
                         Req = fake_request(Socket, ContentType,
-                                           size(BinContent)),
+                                           byte_size(BinContent)),
                         Res = parse_form(Req),
                         [{"submit-name", "Larry"},
                          {"files", {"file1.txt", {"text/plain",[]},
               eof],
     TestCallback = fun (Next) -> test_callback(Next, Expect) end,
     ServerFun = fun (Socket) ->
-                        case gen_tcp:send(Socket, BinContent) of
-                            ok ->
-                                exit(normal)
-                        end
+                        ok = gen_tcp:send(Socket, BinContent),
+			exit(normal)
                 end,
     ClientFun = fun (Socket) ->
                         Req = fake_request(Socket, ContentType,
-                                           size(BinContent)),
+                                           byte_size(BinContent)),
                         Res = parse_multipart_request(Req, TestCallback),
                         {0, <<>>, ok} = Res,
                         ok
               eof],
     TestCallback = fun (Next) -> test_callback(Next, Expect) end,
     ServerFun = fun (Socket) ->
-                        case gen_tcp:send(Socket, BinContent) of
-                            ok ->
-                                exit(normal)
-                        end
+                        ok = gen_tcp:send(Socket, BinContent),
+			exit(normal)
                 end,
     ClientFun = fun (Socket) ->
                         Req = fake_request(Socket, ContentType,
-                                           size(BinContent)),
+                                           byte_size(BinContent)),
                         Res = parse_multipart_request(Req, TestCallback),
                         {0, <<>>, ok} = Res,
                         ok
               eof],
     TestCallback = fun (Next) -> test_callback(Next, Expect) end,
     ServerFun = fun (Socket) ->
-                        case gen_tcp:send(Socket, BinContent) of
-                            ok ->
-                                exit(normal)
-                        end
+                        ok = gen_tcp:send(Socket, BinContent),
+			exit(normal)
                 end,
     ClientFun = fun (Socket) ->
                         Req = fake_request(Socket, ContentType,
-                                           size(BinContent)),
+                                           byte_size(BinContent)),
                         Res = parse_multipart_request(Req, TestCallback),
                         {0, <<>>, ok} = Res,
                         ok

src/mochiweb_request.erl

                            end,
                            LocNums, Data),
     {Bodies, Size};
-
 range_parts(Body0, Ranges) ->
     Body = iolist_to_binary(Body0),
     Size = size(Body),
     [{none, 20}] = parse_range_request("bytes=-20"),
     io:format(".. ok ~n"),
 
-
     %% invalid, single ranges
     io:format("Testing parse_range_request with invalid ranges~n"),
     io:format("1"),
     io:format(".. ok~n"),
 
     Body = <<"012345678901234567890123456789012345678901234567890123456789">>,
-    BodySize = size(Body), %% 60
+    BodySize = byte_size(Body), %% 60
     BodySize = 60,
 
     %% these values assume BodySize =:= 60

src/mochiweb_util.erl

 %%      Fields should be obtained by calling record_info(fields, record_type)
 %%      where record_type is the record type of Record
 record_to_proplist(Record, Fields, TypeKey)
-  when is_tuple(Record),
-       is_list(Fields),
-       size(Record) - 1 =:= length(Fields) ->
+  when tuple_size(Record) - 1 =:= length(Fields) ->
     lists:zip([TypeKey | Fields], tuple_to_list(Record)).
 
 
 
 doit(From, To) ->
     [case file:read_file_info(Filename) of
-         {ok, FileInfo} when FileInfo#file_info.mtime >= From,
-                             FileInfo#file_info.mtime < To ->
+         {ok, #file_info{mtime = Mtime}} when Mtime >= From, Mtime < To ->
              reload(Module);
          {ok, _} ->
              unmodified;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.