Skip to content

Commit

Permalink
BE: Tidy up erlang_service_server match clauses
Browse files Browse the repository at this point in the history
Summary:
D60764433 introduces sending file contents to the Erlang Service together with the request.

We do a binary match to pull out the length, but based it on the manual entry example, which is verbose.

Simplify, by replacing `binary-unit:8` with just `binary`

Reviewed By: michalmuskala

Differential Revision: D62240513

fbshipit-source-id: 48f5039259437c40c9a9f2d5771ce316b1235fc3
  • Loading branch information
alanz authored and facebook-github-bot committed Sep 5, 2024
1 parent e1eb3cd commit bb511c0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions erlang_service/src/erlang_service_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ path_open(ReqId, Name, FileId, IncludeType) ->
case gen_server:call(?SERVER, {request, ReqId,
[unicode:characters_to_binary(add_include_type(Name, FileId, IncludeType))]},
?RECURSIVE_CALLBACK_TIMEOUT) of
{ok, <<SzPath:32, Paths:SzPath/binary-unit:8,
{ok, <<SzPath:32, Paths:SzPath/binary,
NewFileId:32,
Sz:32, FileText:Sz/binary-unit:8>>} ->
Sz:32, FileText:Sz/binary>>} ->
Pid = elp_io_string:new(FileText),
{ok, Pid, binary_to_list(Paths), NewFileId};
X -> X
Expand Down Expand Up @@ -205,10 +205,10 @@ handle_request(<<"ACP", _:64/big, Data/binary>>, State) ->
Paths = collect_paths(Data),
code:add_pathsa(Paths),
{noreply, State};
handle_request(<<"COM", Id:64/big, Sz:32, FileText:Sz/binary-unit:8, Data/binary>>, State) ->
handle_request(<<"COM", Id:64/big, Sz:32, FileText:Sz/binary, Data/binary>>, State) ->
PostProcess = fun(Forms, _FileName) -> term_to_binary({ok, Forms, []}) end,
request(erlang_service_lint, Id, Data, [FileText, PostProcess, false], infinity, State);
handle_request(<<"TXT", Id:64/big, Sz:32, FileText:Sz/binary-unit:8, Data/binary>>, State) ->
handle_request(<<"TXT", Id:64/big, Sz:32, FileText:Sz/binary, Data/binary>>, State) ->
PostProcess =
fun(Forms, _) ->
unicode:characters_to_binary([io_lib:format("~p.~n", [Form]) || Form <- Forms])
Expand Down

0 comments on commit bb511c0

Please sign in to comment.