Skip to content

Commit e8824b4

Browse files
committed
Remove redundant lists and strings indirections
1 parent 20dd698 commit e8824b4

22 files changed

+55
-76
lines changed

big_tests/tests/bosh_SUITE.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ reply_in_time(ConfigIn) ->
691691
server_acks(Config) ->
692692
escalus:story(Config, [{carol, 1}, {geralt, 1}], fun(Carol, Geralt) ->
693693
bosh_set_active(Carol, false),
694-
ExpectedRid = list_to_binary(integer_to_list(get_bosh_rid(Carol))),
694+
ExpectedRid = integer_to_binary(get_bosh_rid(Carol)),
695695
escalus_client:send(Carol, escalus_stanza:chat_to(Geralt, <<"1st!">>)),
696696
escalus_client:send(Carol, escalus_stanza:chat_to(Geralt, <<"2nd!">>)),
697697
timer:sleep(200),
@@ -897,7 +897,7 @@ wait_for_stanza(Client) ->
897897

898898
ack_body(Body, Rid) ->
899899
Attrs = Body#xmlel.attrs,
900-
Ack = {<<"ack">>, list_to_binary(integer_to_list(Rid))},
900+
Ack = {<<"ack">>, integer_to_binary(Rid)},
901901
NewAttrs = lists:keystore(<<"ack">>, 1, Attrs, Ack),
902902
Body#xmlel{attrs = NewAttrs}.
903903

big_tests/tests/common_helper.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ get_bjid(UserSpec) ->
77
<<User/binary,"@",Server/binary>>.
88

99
unprep(Bin) when is_binary(Bin) ->
10-
list_to_binary(string:titlecase(binary_to_list(Bin))).
10+
string:titlecase(Bin).

big_tests/tests/gdpr_SUITE.erl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,15 +1534,14 @@ retrieve_inbox_for_multiple_messages(Config) ->
15341534
retrieve_logs(Config) ->
15351535
escalus:fresh_story(Config, [{alice, 1}],
15361536
fun(Alice) ->
1537-
User = string:to_lower(binary_to_list(escalus_client:username(Alice))),
1538-
Domain = string:to_lower(binary_to_list(escalus_client:server(Alice))),
1539-
JID = string:to_upper(binary_to_list(escalus_client:short_jid(Alice))),
1537+
User = string:lowercase(escalus_client:username(Alice)),
1538+
Domain = string:lowercase(escalus_client:server(Alice)),
1539+
JID = string:uppercase(binary_to_list(escalus_client:short_jid(Alice))),
15401540
#{node := MIM2NodeName} = MIM2Node = distributed_helper:mim2(),
15411541
mongoose_helper:successful_rpc(net_kernel, connect_node, [MIM2NodeName]),
15421542
mongoose_helper:successful_rpc(MIM2Node, error_logger, error_msg,
15431543
["event=disturbance_in_the_force, jid=~s", [JID]]),
1544-
Dir = request_and_unzip_personal_data(list_to_binary(User), list_to_binary(Domain),
1545-
Config),
1544+
Dir = request_and_unzip_personal_data(User, Domain, Config),
15461545
Filename = filename:join(Dir, "logs-" ++ atom_to_list(MIM2NodeName) ++ ".txt"),
15471546
{ok, Content} = file:read_file(Filename),
15481547
{match, _} = re:run(Content, "disturbance_in_the_force")

big_tests/tests/graphql_muc_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,7 @@ assert_default_room_config(Response) ->
19251925
<<"logging">> := false}, get_ok_value(?GET_ROOM_CONFIG_PATH, Response)).
19261926

19271927
atom_to_enum_item(null) -> null;
1928-
atom_to_enum_item(Atom) -> list_to_binary(string:to_upper(atom_to_list(Atom))).
1928+
atom_to_enum_item(Atom) -> string:uppercase(atom_to_binary(Atom)).
19291929

19301930
get_room_name() ->
19311931
Domain = domain_helper:domain(),

big_tests/tests/muc_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4678,7 +4678,7 @@ skip_undefined(Xs) ->
46784678
[X || X <- Xs, X =/= undefined].
46794679

46804680
i2b(X) when is_integer(X) ->
4681-
list_to_binary(integer_to_list(X)).
4681+
integer_to_binary(X).
46824682

46834683
wait_room_range(Client, FromN, ToN) ->
46844684
wait_room_range(Client, 15, FromN-1, FromN, ToN).

big_tests/tests/muc_light_helper.erl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,12 @@ aff_msg_verify_fun(AffUsersChanges) ->
211211
end.
212212

213213
-spec lbin(Bin :: binary()) -> binary().
214-
lbin(Bin) -> list_to_binary(string:to_lower(binary_to_list(Bin))).
215-
214+
lbin(Bin) ->
215+
string:lowercase(Bin).
216216

217217
-spec bin_aff_users(AffUsers :: ct_aff_users()) -> [{LBinJID :: binary(), AffBin :: binary()}].
218218
bin_aff_users(AffUsers) ->
219-
[ {lbin(escalus_client:short_jid(User)), list_to_binary(atom_to_list(Aff))}
219+
[ {lbin(escalus_client:short_jid(User)), atom_to_binary(Aff)}
220220
|| {User, Aff} <- AffUsers ].
221221

222222
-spec verify_aff_users(Items :: [exml:element()], BinAffUsers :: [{binary(), binary()}]) -> [].
@@ -288,7 +288,7 @@ clear_db(HostType) ->
288288

289289
-spec ver(Int :: integer()) -> binary().
290290
ver(Int) ->
291-
<<"ver-", (list_to_binary(integer_to_list(Int)))/binary>>.
291+
<<"ver-", (integer_to_binary(Int))/binary>>.
292292

293293
assert_no_aff_duplicates(AffUsers) ->
294294
Users = [US || {US, _} <- AffUsers],
@@ -302,8 +302,8 @@ assert_no_aff_duplicates(AffUsers) ->
302302

303303
-spec stanza_blocking_set(BlocklistChanges :: [ct_block_item()]) -> exml:element().
304304
stanza_blocking_set(BlocklistChanges) ->
305-
Items = [#xmlel{ name = list_to_binary(atom_to_list(What)),
306-
attrs = [{<<"action">>, list_to_binary(atom_to_list(Action))}],
305+
Items = [#xmlel{ name = atom_to_binary(What),
306+
attrs = [{<<"action">>, atom_to_binary(Action)}],
307307
children = [#xmlcdata{ content = Who }] }
308308
|| {What, Action, Who} <- BlocklistChanges],
309309
escalus_stanza:to(escalus_stanza:iq_set(?NS_MUC_LIGHT_BLOCKING, Items), muc_host()).

big_tests/tests/oauth_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ serialize(ServerSideToken) ->
435435
end.
436436

437437
to_lower(B) when is_binary(B) ->
438-
list_to_binary(string:to_lower(binary_to_list(B))).
438+
string:lowercase(B).
439439

440440
required_modules() ->
441441
KeyOpts = #{backend => ct_helper:get_internal_database(),

big_tests/tests/offline_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ make_chat_text(I) ->
406406
<<"Hi, Offline ", Number/binary>>.
407407

408408
make_message_with_expiry(Target, Expiry, Text) ->
409-
ExpiryBin = list_to_binary(integer_to_list(Expiry)),
409+
ExpiryBin = integer_to_binary(Expiry),
410410
Stanza = escalus_stanza:chat_to(Target, Text),
411411
#xmlel{children = Children} = Stanza,
412412
ExpiryElem = #xmlel{name = <<"x">>,

big_tests/tests/push_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ push_notification(PubsubJID, Payload, PublishOpts) ->
774774

775775
bare_jid(JIDOrClient) ->
776776
ShortJID = escalus_client:short_jid(JIDOrClient),
777-
list_to_binary(string:to_lower(binary_to_list(ShortJID))).
777+
string:lowercase(ShortJID).
778778

779779
add_pubsub_jid(Config) ->
780780
CaseName = proplists:get_value(case_name, Config),

big_tests/tests/push_http_SUITE.erl

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ process_notification(Req) ->
161161

162162
check_default_format(From, To, Body, Msg) ->
163163
Attrs = lists:map(fun(P) -> list_to_tuple(binary:split(P, <<$=>>)) end, binary:split(Msg, <<$&>>, [global])),
164-
?assertEqual(to_lower(escalus_client:username(From)), proplists:get_value(<<"author">>, Attrs)),
165-
?assertEqual(to_lower(escalus_client:username(To)), proplists:get_value(<<"receiver">>, Attrs)),
164+
?assertEqual(string:lowercase(escalus_client:username(From)),
165+
proplists:get_value(<<"author">>, Attrs)),
166+
?assertEqual(string:lowercase(escalus_client:username(To)),
167+
proplists:get_value(<<"receiver">>, Attrs)),
166168
?assertEqual(Body, proplists:get_value(<<"message">>, Attrs)),
167169
?assertEqual(<<"localhost">>, proplists:get_value(<<"server">>, Attrs)),
168170
ok.
@@ -221,15 +223,6 @@ custom_module_code_2() ->
221223
"
222224
.
223225

224-
to_lower(B) ->
225-
list_to_binary(
226-
string:to_lower(
227-
binary_to_list(
228-
B
229-
)
230-
)
231-
).
232-
233226
send(Alice, Bob, Body) ->
234227
Stanza = escalus_stanza:chat_to(Bob, Body),
235228
escalus_client:send(Alice, Stanza).

0 commit comments

Comments
 (0)