]> granicus.if.org Git - ejabberd/commitdiff
Get rid of excessive (io)list_to_binary/1 calls
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Thu, 24 Nov 2016 12:06:06 +0000 (15:06 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Thu, 24 Nov 2016 12:06:06 +0000 (15:06 +0300)
26 files changed:
src/acl.erl
src/ejabberd_access_permissions.erl
src/ejabberd_admin.erl
src/ejabberd_bosh.erl
src/ejabberd_captcha.erl
src/ejabberd_http.erl
src/ejabberd_http_bind.erl
src/ejabberd_piefxis.erl
src/ejabberd_riak.erl
src/ejabberd_system_monitor.erl
src/ejabberd_web_admin.erl
src/jlib.erl
src/mod_configure.erl
src/mod_irc.erl
src/mod_irc_connection.erl
src/mod_muc_log.erl
src/mod_offline.erl
src/mod_pubsub.erl
src/mod_register.erl
src/mod_sip_proxy.erl
src/mod_sip_registrar.erl
src/mod_stats.erl
src/mod_version.erl
src/pubsub_db_sql.erl
src/pubsub_subscription.erl
src/pubsub_subscription_sql.erl

index e3fdfcae1c0fcee9882c534e9e0839f9e80fd88e..595228ee9fe88ad35bbbfd1abdb988f65f45f765 100644 (file)
@@ -342,7 +342,7 @@ acl_rule_verify({node_glob, {UR, SR}}) when is_binary(UR), is_binary(SR) ->
 acl_rule_verify(_Spec) ->
     false.
 invalid_syntax(Msg, Data) ->
-    throw({invalid_syntax, iolist_to_binary(io_lib:format(Msg, Data))}).
+    throw({invalid_syntax, (str:format(Msg, Data))}).
 
 acl_rules_verify([{acl, Name} | Rest], true) when is_atom(Name) ->
     acl_rules_verify(Rest, true);
index 7ce75aa9c8523e3f03b3fa5425d2215dd21e4cf0..60ad68a291380c968802a4f9af263ee78e8fa703 100644 (file)
@@ -532,10 +532,10 @@ key_split([{Arg, Value} | Rest], Results, Order, Required, Duplicates) ->
     end.
 
 report_error(Format, Args) ->
-    throw({invalid_syntax, iolist_to_binary(io_lib:format(Format, Args))}).
+    throw({invalid_syntax, (str:format(Format, Args))}).
 
 parse_error(Format, Args) ->
-    {error, iolist_to_binary(io_lib:format(Format, Args))}.
+    {error, (str:format(Format, Args))}.
 
 opt_type(api_permissions) ->
     fun parse_api_permissions/1;
index 8622ea8d0853e9e6174281c5cd77badc5ef1d436..99aa517941bdab7f2969205f695664e3b2b756b6 100644 (file)
@@ -302,8 +302,8 @@ set_loglevel(LogLevel) ->
 %%%
 
 stop_kindly(DelaySeconds, AnnouncementTextString) ->
-    Subject = list_to_binary(io_lib:format("Server stop in ~p seconds!", [DelaySeconds])),
-    WaitingDesc = list_to_binary(io_lib:format("Waiting ~p seconds", [DelaySeconds])),
+    Subject = (str:format("Server stop in ~p seconds!", [DelaySeconds])),
+    WaitingDesc = (str:format("Waiting ~p seconds", [DelaySeconds])),
     AnnouncementText = list_to_binary(AnnouncementTextString),
     Steps = [
             {"Stopping ejabberd port listeners",
@@ -337,8 +337,7 @@ stop_kindly(DelaySeconds, AnnouncementTextString) ->
     ok.
 
 send_service_message_all_mucs(Subject, AnnouncementText) ->
-    Message = list_to_binary(
-                io_lib:format("~s~n~s", [Subject, AnnouncementText])),
+    Message = str:format("~s~n~s", [Subject, AnnouncementText]),
     lists:foreach(
       fun(ServerHost) ->
              MUCHost = gen_mod:get_module_opt_host(
index 1dc103aee952da4f4e682426d3e52a89688dfacd..b94184167afd8279dc7c5b83439fc0382a50eb84 100644 (file)
@@ -807,7 +807,7 @@ encode_body(#body{attrs = Attrs, els = Els}, Type) ->
                                 true -> {AmK, <<"true">>};
                                 false -> {AmK, <<"false">>};
                                 I when is_integer(I), I >= 0 ->
-                                    {AmK, iolist_to_binary(integer_to_list(I))};
+                                    {AmK, integer_to_binary(I)};
                                 _ -> {AmK, V}
                               end;
                           ({K, V}) -> {K, V}
index a122eda8ea15a1b90ba9ea98a1ee4abff69e2424..f959d7f30a13d884f1da3e25dd01faeea5ea8a4c 100644 (file)
@@ -103,7 +103,7 @@ create_captcha(SID, From, To, Lang, Limiter, Args) ->
          BodyString1 = translate:translate(Lang,
                                            <<"Your messages to ~s are being blocked. "
                                              "To unblock them, visit ~s">>),
-         BodyString = iolist_to_binary(io_lib:format(BodyString1,
+         BodyString = (str:format(BodyString1,
                                                       [JID, get_url(Id)])),
          Body = xmpp:mk_text(BodyString, Lang),
          OOB = #oob_x{url = get_url(Id)},
index c6c31a971931ee72ee8f32f4868396af49f2ba18..c0c7bbbd6863aef744261c8d4ba51e3e043c01cc 100644 (file)
@@ -550,12 +550,12 @@ make_xhtml_output(State, Status, Headers, XHTML) ->
                   of
                 {value, _} ->
                     [{<<"Content-Length">>,
-                      iolist_to_binary(integer_to_list(byte_size(Data)))}
+                      integer_to_binary(byte_size(Data))}
                      | Headers];
                 _ ->
                     [{<<"Content-Type">>, <<"text/html; charset=utf-8">>},
                      {<<"Content-Length">>,
-                      iolist_to_binary(integer_to_list(byte_size(Data)))}
+                      integer_to_binary(byte_size(Data))}
                      | Headers]
               end,
     HeadersOut = case {State#state.request_version,
@@ -577,7 +577,7 @@ make_xhtml_output(State, Status, Headers, XHTML) ->
                  end,
                  HeadersOut),
     SL = [Version,
-         iolist_to_binary(integer_to_list(Status)), <<" ">>,
+         integer_to_binary(Status), <<" ">>,
          code_to_phrase(Status), <<"\r\n">>],
     Data2 = case State#state.request_method of
              'HEAD' -> <<"">>;
index db529e69e7205d73dc7badff6f03e73310bd1489..ea64b3cdfa5cafa5a388c9f06000e88a32233a22 100644 (file)
@@ -972,21 +972,17 @@ prepare_outpacket_response(#http_bind{id = Sid,
                                                  [{<<"xmlns">>, ?NS_HTTP_BIND},
                                                   {<<"sid">>, Sid},
                                                   {<<"wait">>,
-                                                   iolist_to_binary(integer_to_list(Wait))},
+                                                   integer_to_binary(Wait)},
                                                   {<<"requests">>,
-                                                   iolist_to_binary(integer_to_list(Hold
-                                                                                      +
-                                                                                      1))},
+                                                   integer_to_binary(Hold + 1)},
                                                   {<<"inactivity">>,
-                                                   iolist_to_binary(integer_to_list(trunc(MaxInactivity
-                                                                                            /
-                                                                                            1000)))},
+                                                   integer_to_binary(
+                                                     trunc(MaxInactivity / 1000))},
                                                   {<<"maxpause">>,
-                                                   iolist_to_binary(integer_to_list(MaxPause))},
+                                                   integer_to_binary(MaxPause)},
                                                   {<<"polling">>,
-                                                   iolist_to_binary(integer_to_list(trunc((?MIN_POLLING)
-                                                                                            /
-                                                                                            1000000)))},
+                                                   integer_to_binary(
+                                                     trunc((?MIN_POLLING) / 1000000))},
                                                   {<<"ver">>, ?BOSH_VERSION},
                                                   {<<"from">>, From},
                                                   {<<"secure">>, <<"true">>}]
index 0e79c991315396fcc515d6eb19478ae50cecc509..b6f90ccf844ffc72cef3eb8f4a55c2af642b6988 100644 (file)
@@ -196,7 +196,7 @@ format_scram_password({StoredKey, ServerKey, Salt, IterationCount}) ->
   StoredKeyB64 = base64:encode(StoredKey),
   ServerKeyB64 = base64:encode(ServerKey),
   SaltB64 = base64:encode(Salt),
-  IterationCountBin = list_to_binary(integer_to_list(IterationCount)),
+  IterationCountBin = (integer_to_binary(IterationCount)),
   <<"scram:", StoredKeyB64/binary, ",", ServerKeyB64/binary, ",", SaltB64/binary, ",", IterationCountBin/binary>>.
 
 parse_scram_password(PassData) ->
@@ -206,7 +206,7 @@ parse_scram_password(PassData) ->
     storedkey = StoredKeyB64,
     serverkey = ServerKeyB64,
     salt      = SaltB64,
-    iterationcount = list_to_integer(binary_to_list(IterationCountBin))
+    iterationcount = (binary_to_integer(IterationCountBin))
   }.
 
 -spec get_vcard(binary(), binary()) -> [xmlel()].
@@ -554,9 +554,8 @@ stop(Fmt, Args) ->
 
 make_filename_template() ->
     {{Year, Month, Day}, {Hour, Minute, Second}} = calendar:local_time(),
-    list_to_binary(
-      io_lib:format("~4..0w~2..0w~2..0w-~2..0w~2..0w~2..0w",
-                   [Year, Month, Day, Hour, Minute, Second])).
+    str:format("~4..0w~2..0w~2..0w-~2..0w~2..0w~2..0w",
+              [Year, Month, Day, Hour, Minute, Second]).
 
 make_main_basefilename(Dir, FnT) ->
     Filename2 = <<FnT/binary, ".xml">>,
index 575810acc7577b53d5beadea503be7592a553c0c..44628d1c2ebe79915fa24534d9f3ee43d1cdaaf8 100644 (file)
@@ -428,7 +428,7 @@ map_key(Obj, _, _) ->
          <<"b_", B/binary>> ->
              B;
          <<"i_", B/binary>> ->
-             list_to_integer(binary_to_list(B));
+             (binary_to_integer(B));
          B ->
              erlang:binary_to_term(B)
      end].
@@ -483,7 +483,7 @@ encode_index_key(Idx, Key) ->
 encode_key(Bin) when is_binary(Bin) ->
     <<"b_", Bin/binary>>;
 encode_key(Int) when is_integer(Int) ->
-    <<"i_", (list_to_binary(integer_to_list(Int)))/binary>>;
+    <<"i_", ((integer_to_binary(Int)))/binary>>;
 encode_key(Term) ->
     erlang:term_to_binary(Term).
 
@@ -519,7 +519,7 @@ log_error(_, _, _) ->
     ok.
 
 make_invalid_object(Val) ->
-    list_to_binary(io_lib:fwrite("Invalid object: ~p", [Val])).
+    (str:format("Invalid object: ~p", [Val])).
 
 get_random_pid() ->
     PoolPid = ejabberd_riak_sup:get_random_pid(),
index df6af1c959a6f841047d54e27e66e7590fc6aa79..5d52a041dbf03c931b90283c8795c0c28b2f83ac 100644 (file)
@@ -180,10 +180,9 @@ process_large_heap(Pid, Info) ->
     Host = (?MYNAME),
     JIDs = get_admin_jids(),
     DetailedInfo = detailed_info(Pid),
-    Body = iolist_to_binary(
-             io_lib:format("(~w) The process ~w is consuming too "
-                           "much memory:~n~p~n~s",
-                           [node(), Pid, Info, DetailedInfo])),
+    Body = str:format("(~w) The process ~w is consuming too "
+                     "much memory:~n~p~n~s",
+                     [node(), Pid, Info, DetailedInfo]),
     From = jid:make(<<"">>, Host, <<"watchdog">>),
     Hint = [#hint{type = 'no-permanent-store'}],
     lists:foreach(
index bf17c8ab19742eafa60ede22033eec0877ffaaee..3836beda76c63f318076cd90fa62049b26325bdb 100644 (file)
@@ -763,8 +763,8 @@ process_admin(Host,
                   [?XAE(<<"form">>,
                         [{<<"action">>, <<"">>}, {<<"method">>, <<"post">>}]++direction(ltr),
                         [?TEXTAREA(<<"acls">>,
-                                   (iolist_to_binary(integer_to_list(lists:max([16,
-                                                                                NumLines])))),
+                                   (integer_to_binary(lists:max([16,
+                                                                                NumLines]))),
                                    <<"80">>, <<(iolist_to_binary(ACLsP))/binary, ".">>),
                          ?BR,
                          ?INPUTT(<<"submit">>, <<"submit">>, <<"Submit">>)])],
@@ -865,8 +865,8 @@ process_admin(Host,
                   [?XAE(<<"form">>,
                         [{<<"action">>, <<"">>}, {<<"method">>, <<"post">>}]++direction(ltr),
                         [?TEXTAREA(<<"access">>,
-                                   (iolist_to_binary(integer_to_list(lists:max([16,
-                                                                                NumLines])))),
+                                   (integer_to_binary(lists:max([16,
+                                                                                NumLines]))),
                                    <<"80">>, <<(iolist_to_binary(AccessP))/binary, ".">>),
                          ?BR,
                          ?INPUTT(<<"submit">>, <<"submit">>, <<"Submit">>)])],
@@ -926,7 +926,7 @@ process_admin(Host,
              Rs1 -> Rs1
            end,
     make_xhtml([?XC(<<"h1">>,
-                   list_to_binary(io_lib:format(
+                   (str:format(
                                      ?T(<<"~s access rule configuration">>),
                                      [SName])))]
                 ++
@@ -1141,7 +1141,7 @@ acl_spec_select(ID, Opt) ->
 %% @spec (T::any()) -> StringLine::string()
 term_to_string(T) ->
     StringParagraph =
-       iolist_to_binary(io_lib:format("~1000000p", [T])),
+       (str:format("~1000000p", [T])),
     ejabberd_regexp:greplace(StringParagraph, <<"\\n ">>,
                             <<"">>).
 
@@ -1506,7 +1506,7 @@ list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
                                                    {{Year, Month, Day},
                                                     {Hour, Minute, Second}} =
                                                        calendar:now_to_local_time(TimeStamp),
-                                                   iolist_to_binary(io_lib:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
+                                                   (str:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
                                                                                   [Year,
                                                                                    Month,
                                                                                    Day,
@@ -1683,14 +1683,14 @@ user_info(User, Server, Query, Lang) ->
                                            Shift rem 1000000, 0},
                               {{Year, Month, Day}, {Hour, Minute, Second}} =
                                   calendar:now_to_local_time(TimeStamp),
-                              iolist_to_binary(io_lib:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
+                              (str:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
                                                              [Year, Month, Day,
                                                               Hour, Minute,
                                                               Second]))
                         end;
                     _ -> ?T(<<"Online">>)
                   end,
-    [?XC(<<"h1">>, list_to_binary(io_lib:format(?T(<<"User ~s">>),
+    [?XC(<<"h1">>, (str:format(?T(<<"User ~s">>),
                                                 [us_to_list(US)])))]
       ++
       case Res of
@@ -1773,9 +1773,7 @@ list_last_activity(Host, Lang, Integral, Period) ->
                       [?XAE(<<"li">>,
                             [{<<"style">>,
                               <<"width:",
-                                (iolist_to_binary(integer_to_list(trunc(90 * V
-                                                                          /
-                                                                          Max))))/binary,
+                                (integer_to_binary(trunc(90 * V / Max)))/binary,
                                 "%;">>}],
                             [{xmlcdata, pretty_string_int(V)}])
                        || V <- Hist ++ Tail])]
@@ -1850,7 +1848,7 @@ get_node(global, Node, [], Query, Lang) ->
     Base = get_base_path(global, Node),
     MenuItems2 = make_menu_items(global, Node, Base, Lang),
     [?XC(<<"h1">>,
-        list_to_binary(io_lib:format(?T(<<"Node ~p">>), [Node])))]
+        (str:format(?T(<<"Node ~p">>), [Node])))]
       ++
       case Res of
        ok -> [?XREST(<<"Submitted">>)];
@@ -1875,7 +1873,7 @@ get_node(global, Node, [], Query, Lang) ->
 get_node(Host, Node, [], _Query, Lang) ->
     Base = get_base_path(Host, Node),
     MenuItems2 = make_menu_items(Host, Node, Base, Lang),
-    [?XC(<<"h1">>, list_to_binary(io_lib:format(?T(<<"Node ~p">>), [Node]))),
+    [?XC(<<"h1">>, (str:format(?T(<<"Node ~p">>), [Node]))),
      ?XE(<<"ul">>,
         ([?LI([?ACT(<<Base/binary, "modules/">>,
                     <<"Modules">>)])]
@@ -1934,7 +1932,7 @@ get_node(global, Node, [<<"db">>], Query, Lang) ->
                           end,
                           STables),
          [?XC(<<"h1">>,
-              list_to_binary(io_lib:format(?T(<<"Database Tables at ~p">>),
+              (str:format(?T(<<"Database Tables at ~p">>),
                                             [Node]))
          )]
            ++
@@ -1970,9 +1968,9 @@ get_node(global, Node, [<<"backup">>], Query, Lang) ->
             ok -> [?XREST(<<"Submitted">>)];
             {error, Error} ->
                 [?XRES(<<(?T(<<"Error">>))/binary, ": ",
-                         (list_to_binary(io_lib:format("~p", [Error])))/binary>>)]
+                         ((str:format("~p", [Error])))/binary>>)]
           end,
-    [?XC(<<"h1">>, list_to_binary(io_lib:format(?T(<<"Backup of ~p">>), [Node])))]
+    [?XC(<<"h1">>, (str:format(?T(<<"Backup of ~p">>), [Node])))]
       ++
       ResS ++
        [?XCT(<<"p">>,
@@ -2124,7 +2122,7 @@ get_node(global, Node, [<<"ports">>], Query, Lang) ->
            {'EXIT', _Reason} -> error;
            {is_added, ok} -> ok;
            {is_added, {error, Reason}} ->
-               {error, iolist_to_binary(io_lib:format("~p", [Reason]))};
+               {error, (str:format("~p", [Reason]))};
            _ -> nothing
          end,
     NewPorts = lists:sort(ejabberd_cluster:call(Node, ejabberd_config,
@@ -2161,7 +2159,7 @@ get_node(Host, Node, [<<"modules">>], Query, Lang)
          end,
     NewModules = lists:sort(ejabberd_cluster:call(Node, gen_mod,
                                     loaded_modules_with_opts, [Host])),
-    H1String = list_to_binary(io_lib:format(?T(<<"Modules at ~p">>), [Node])),
+    H1String = (str:format(?T(<<"Modules at ~p">>), [Node])),
     (?H1GL(H1String, <<"modulesoverview">>,
           <<"Modules Overview">>))
       ++
@@ -2177,10 +2175,10 @@ get_node(Host, Node, [<<"modules">>], Query, Lang)
 get_node(global, Node, [<<"stats">>], _Query, Lang) ->
     UpTime = ejabberd_cluster:call(Node, erlang, statistics,
                      [wall_clock]),
-    UpTimeS = list_to_binary(io_lib:format("~.3f",
+    UpTimeS = (str:format("~.3f",
                                            [element(1, UpTime) / 1000])),
     CPUTime = ejabberd_cluster:call(Node, erlang, statistics, [runtime]),
-    CPUTimeS = list_to_binary(io_lib:format("~.3f",
+    CPUTimeS = (str:format("~.3f",
                                             [element(1, CPUTime) / 1000])),
     OnlineUsers = ejabberd_sm:connected_users_number(),
     TransactionsCommitted = ejabberd_cluster:call(Node, mnesia,
@@ -2192,7 +2190,7 @@ get_node(global, Node, [<<"stats">>], _Query, Lang) ->
     TransactionsLogged = ejabberd_cluster:call(Node, mnesia, system_info,
                                  [transaction_log_writes]),
     [?XC(<<"h1">>,
-        list_to_binary(io_lib:format(?T(<<"Statistics of ~p">>), [Node]))),
+        (str:format(?T(<<"Statistics of ~p">>), [Node]))),
      ?XAE(<<"table">>, [],
          [?XE(<<"tbody">>,
               [?XE(<<"tr">>,
@@ -2256,11 +2254,11 @@ get_node(global, Node, [<<"update">>], Query, Lang) ->
                      (BeamsLis ++ SelectButtons))
           end,
     FmtScript = (?XC(<<"pre">>,
-                    list_to_binary(io_lib:format("~p", [Script])))),
+                    (str:format("~p", [Script])))),
     FmtLowLevelScript = (?XC(<<"pre">>,
-                            list_to_binary(io_lib:format("~p", [LowLevelScript])))),
+                            (str:format("~p", [LowLevelScript])))),
     [?XC(<<"h1">>,
-        list_to_binary(io_lib:format(?T(<<"Update ~p">>), [Node])))]
+        (str:format(?T(<<"Update ~p">>), [Node])))]
       ++
       case Res of
        ok -> [?XREST(<<"Submitted">>)];
@@ -2482,7 +2480,7 @@ node_ports_to_xhtml(Ports, Lang) ->
                                                   SModule, <<"15">>)]),
                                      ?XAE(<<"td">>, direction(ltr),
                                          [?TEXTAREA(<<"opts", SSPort/binary>>,
-                                                    (iolist_to_binary(integer_to_list(NumLines))),
+                                                    (integer_to_binary(NumLines)),
                                                     <<"35">>, SOptsClean)]),
                                      ?XE(<<"td">>,
                                          [?INPUTT(<<"submit">>,
@@ -2625,7 +2623,7 @@ node_modules_to_xhtml(Modules, Lang) ->
                                     [?XC(<<"td">>, SModule),
                                      ?XAE(<<"td">>, direction(ltr),
                                          [?TEXTAREA(<<"opts", SModule/binary>>,
-                                                    (iolist_to_binary(integer_to_list(NumLines))),
+                                                    (integer_to_binary(NumLines)),
                                                     <<"40">>, SOpts)]),
                                      ?XE(<<"td">>,
                                          [?INPUTT(<<"submit">>,
@@ -2707,11 +2705,11 @@ node_update_parse_query(Node, Query) ->
            {ok, _} -> ok;
            {error, Error} ->
                ?ERROR_MSG("~p~n", [Error]),
-               {error, iolist_to_binary(io_lib:format("~p", [Error]))};
+               {error, (str:format("~p", [Error]))};
            {badrpc, Error} ->
                ?ERROR_MSG("Bad RPC: ~p~n", [Error]),
                {error,
-                <<"Bad RPC: ", (iolist_to_binary(io_lib:format("~p", [Error])))/binary>>}
+                <<"Bad RPC: ", ((str:format("~p", [Error])))/binary>>}
          end;
       _ -> nothing
     end.
@@ -2776,7 +2774,7 @@ pretty_print_xml(#xmlel{name = Name, attrs = Attrs,
 element_to_list(X) when is_atom(X) ->
     iolist_to_binary(atom_to_list(X));
 element_to_list(X) when is_integer(X) ->
-    iolist_to_binary(integer_to_list(X)).
+    integer_to_binary(X).
 
 list_to_element(Bin) ->
     {ok, Tokens, _} = erl_scan:string(binary_to_list(Bin)),
@@ -2784,8 +2782,8 @@ list_to_element(Bin) ->
     Element.
 
 url_func({user_diapason, From, To}) ->
-    <<(iolist_to_binary(integer_to_list(From)))/binary, "-",
-      (iolist_to_binary(integer_to_list(To)))/binary, "/">>;
+    <<(integer_to_binary(From))/binary, "-",
+      (integer_to_binary(To))/binary, "/">>;
 url_func({users_queue, Prefix, User, _Server}) ->
     <<Prefix/binary, "user/", User/binary, "/queue/">>;
 url_func({user, Prefix, User, _Server}) ->
@@ -2800,7 +2798,7 @@ cache_control_public() ->
 
 %% Transform 1234567890 into "1,234,567,890"
 pretty_string_int(Integer) when is_integer(Integer) ->
-    pretty_string_int(iolist_to_binary(integer_to_list(Integer)));
+    pretty_string_int(integer_to_binary(Integer));
 pretty_string_int(String) when is_binary(String) ->
     {_, Result} = lists:foldl(fun (NewNumber, {3, Result}) ->
                                      {1, <<NewNumber, $,, Result/binary>>};
index f7dbebd860e22ce3fbacb02afcd099df5e4fa03b..096ef40127644d291fdc814085845896d0292dd3 100644 (file)
@@ -677,14 +677,14 @@ timestamp_to_iso({{Year, Month, Day},
 %% http://xmpp.org/extensions/xep-0091.html#time
 timestamp_to_legacy({{Year, Month, Day},
                   {Hour, Minute, Second}}) ->
-    iolist_to_binary(io_lib:format("~4..0B~2..0B~2..0BT~2..0B:~2..0B:~2..0B",
+    (str:format("~4..0B~2..0B~2..0BT~2..0B:~2..0B:~2..0B",
                                    [Year, Month, Day, Hour, Minute, Second])).
 
 -spec timestamp_to_iso_basic(calendar:datetime()) -> binary().
 %% This is the ISO 8601 basic bormat
 timestamp_to_iso_basic({{Year, Month, Day},
                   {Hour, Minute, Second}}) ->
-    iolist_to_binary(io_lib:format("~4..0B~2..0B~2..0BT~2..0B~2..0B~2..0B",
+    (str:format("~4..0B~2..0B~2..0BT~2..0B~2..0B~2..0B",
                                    [Year, Month, Day, Hour, Minute, Second])).
 
 -spec now_to_utc_string(erlang:timestamp()) -> binary().
@@ -703,7 +703,7 @@ now_to_utc_string({MegaSecs, Secs, MicroSecs}, Precision) ->
       Max ->
          now_to_utc_string({MegaSecs, Secs + 1, 0}, Precision);
       FracOfSec ->
-         list_to_binary(io_lib:format("~4..0B-~2..0B-~2..0BT"
+         (str:format("~4..0B-~2..0B-~2..0BT"
                                       "~2..0B:~2..0B:~2..0B.~*..0BZ",
                                       [Year, Month, Day, Hour, Minute, Second,
                                        Precision, FracOfSec]))
@@ -725,7 +725,7 @@ now_to_local_string({MegaSecs, Secs, MicroSecs}) ->
                        end,
     {{Year, Month, Day}, {Hour, Minute, Second}} =
        LocalTime,
-    list_to_binary(io_lib:format("~4..0B-~2..0B-~2..0BT~2..0B:~2..0B:~2..0B.~6."
+    (str:format("~4..0B-~2..0B-~2..0BT~2..0B:~2..0B:~2..0B.~6."
                                  ".0B~s~2..0B:~2..0B",
                                  [Year, Month, Day, Hour, Minute, Second,
                                   MicroSecs, Sign, H, M])).
index fc274dc03732dde5a0bd263beb65632654300993..436d736e6cbfbc49fb71e5b9aed44f62bffb44ff 100644 (file)
@@ -680,9 +680,9 @@ get_all_vh_users(Host) ->
                lists:map(fun (K) ->
                                  L = K + M - 1,
                                  Node = <<"@",
-                                          (iolist_to_binary(integer_to_list(K)))/binary,
+                                          (integer_to_binary(K))/binary,
                                           "-",
-                                          (iolist_to_binary(integer_to_list(L)))/binary>>,
+                                          (integer_to_binary(L))/binary>>,
                                  {FS, FU} = lists:nth(K, SUsers),
                                  {LS, LU} = if L < N -> lists:nth(L, SUsers);
                                                true -> lists:last(SUsers)
@@ -707,8 +707,7 @@ get_outgoing_s2s(Host, Lang) ->
                       Host == FH orelse str:suffix(DotHost, FH)],
          lists:map(
            fun (T) ->
-                   Name = iolist_to_binary(
-                            io_lib:format(?T(Lang, <<"To ~s">>),[T])),
+                   Name = str:format(?T(Lang, <<"To ~s">>),[T]),
                    #disco_item{jid = jid:make(Host),
                                node = <<"outgoing s2s/", T/binary>>,
                                name = Name}
@@ -722,8 +721,7 @@ get_outgoing_s2s(Host, Lang, To) ->
          lists:map(
            fun ({F, _T}) ->
                    Node = <<"outgoing s2s/", To/binary, "/", F/binary>>,
-                   Name = iolist_to_binary(
-                            io_lib:format(?T(Lang, <<"From ~s">>), [F])),
+                   Name = str:format(?T(Lang, <<"From ~s">>), [F]),
                    #disco_item{jid = jid:make(Host), node = Node, name = Name}
            end,
            lists:keysort(1,
@@ -1082,14 +1080,13 @@ get_form(_Host,
                                   label = ?T(Lang, <<"Message body">>)}]}};
 get_form(Host, [<<"config">>, <<"acls">>], Lang) ->
     ACLs = str:tokens(
-            iolist_to_binary(
-              io_lib:format("~p.",
-                            [mnesia:dirty_select(
-                               acl,
-                               ets:fun2ms(
-                                 fun({acl, {Name, H}, Spec}) when H == Host ->
-                                         {acl, Name, Spec}
-                                 end))])),
+            str:format("~p.",
+                       [mnesia:dirty_select(
+                          acl,
+                          ets:fun2ms(
+                            fun({acl, {Name, H}, Spec}) when H == Host ->
+                                    {acl, Name, Spec}
+                            end))]),
             <<"\n">>),
     {result,
      #xdata{title = ?T(Lang, <<"Access Control List Configuration">>),
@@ -1101,14 +1098,13 @@ get_form(Host, [<<"config">>, <<"acls">>], Lang) ->
                                   values = ACLs}]}};
 get_form(Host, [<<"config">>, <<"access">>], Lang) ->
     Accs = str:tokens(
-            iolist_to_binary(
-              io_lib:format("~p.",
-                            [mnesia:dirty_select(
-                               access,
-                               ets:fun2ms(
-                                 fun({access, {Name, H}, Acc}) when H == Host ->
-                                         {access, Name, Acc}
-                                 end))])),
+            str:format("~p.",
+                       [mnesia:dirty_select(
+                          access,
+                          ets:fun2ms(
+                            fun({access, {Name, H}, Acc}) when H == Host ->
+                                    {access, Name, Acc}
+                            end))]),
             <<"\n">>),
     {result,
      #xdata{title = ?T(Lang, <<"Access Configuration">>),
@@ -1199,9 +1195,7 @@ get_form(_Host, ?NS_ADMINL(<<"user-stats">>), Lang) ->
                                   required = true}]}};
 get_form(Host,
         ?NS_ADMINL(<<"get-registered-users-num">>), Lang) ->
-    Num = list_to_binary(
-            io_lib:format("~p",
-                         [ejabberd_auth:get_vh_registered_users_number(Host)])),
+    Num = integer_to_binary(ejabberd_auth:get_vh_registered_users_number(Host)),
     {result, completed,
      #xdata{type = form,
            fields = [?HFIELD(),
@@ -1211,9 +1205,7 @@ get_form(Host,
                                   values = [Num]}]}};
 get_form(Host, ?NS_ADMINL(<<"get-online-users-num">>),
         Lang) ->
-    Num = list_to_binary(
-            io_lib:format("~p",
-                          [length(ejabberd_sm:get_vh_session_list(Host))])),
+    Num = integer_to_binary(ejabberd_sm:get_vh_session_number(Host)),
     {result, completed,
      #xdata{type = form,
            fields = [?HFIELD(),
@@ -1641,7 +1633,7 @@ set_form(From, Host,
                        TimeStamp = {Shift div 1000000, Shift rem 1000000, 0},
                        {{Year, Month, Day}, {Hour, Minute, Second}} =
                            calendar:now_to_local_time(TimeStamp),
-                       iolist_to_binary(io_lib:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
+                       (str:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
                                                       [Year, Month, Day, Hour,
                                                        Minute, Second]))
                  end;
index 3dd0e492dc56333c376ff28ba128ae75d08cd914..77bf34801954faab9640728a745bdb7f46cdebc6 100644 (file)
@@ -464,24 +464,23 @@ get_form(ServerHost, Host, From, Lang) ->
                               var = <<"username">>,
                               values = [Username]},
                  #xdata_field{type = fixed,
-                              values = [iolist_to_binary(
-                                          io_lib:format(
-                                            translate:translate(
-                                              Lang,
-                                              <<"If you want to specify"
-                                                " different ports, "
-                                                "passwords, encodings "
-                                                "for IRC servers, "
-                                                "fill this list with "
-                                                "values in format "
-                                                "'{\"irc server\", "
-                                                "\"encoding\", port, "
-                                                "\"password\"}'.  "
-                                                "By default this "
-                                                "service use \"~s\" "
-                                                "encoding, port ~p, "
-                                                "empty password.">>),
-                                            [DefaultEncoding, ?DEFAULT_IRC_PORT]))]},
+                              values = [str:format(
+                                          translate:translate(
+                                            Lang,
+                                            <<"If you want to specify"
+                                              " different ports, "
+                                              "passwords, encodings "
+                                              "for IRC servers, "
+                                              "fill this list with "
+                                              "values in format "
+                                              "'{\"irc server\", "
+                                              "\"encoding\", port, "
+                                              "\"password\"}'.  "
+                                              "By default this "
+                                              "service use \"~s\" "
+                                              "encoding, port ~p, "
+                                              "empty password.">>),
+                                          [DefaultEncoding, ?DEFAULT_IRC_PORT])]},
                  #xdata_field{type = fixed,
                               values = [translate:translate(
                                           Lang,
@@ -493,11 +492,10 @@ get_form(ServerHost, Host, From, Lang) ->
                               label = translate:translate(
                                         Lang, <<"Connections parameters">>),
                               var = <<"connections_params">>,
-                              values = str:tokens(list_to_binary(
-                                                    io_lib:format(
-                                                      "~p.",
-                                                      [conn_params_to_list(
-                                                         ConnectionsParams)])),
+                              values = str:tokens(str:format(
+                                                    "~p.",
+                                                    [conn_params_to_list(
+                                                       ConnectionsParams)]),
                                                   <<"\n">>)}],
            X = #xdata{type = form,
                       title = <<(translate:translate(
@@ -657,11 +655,10 @@ adhoc_join(From, To, #adhoc_command{lang = Lang, xdata = X} = Request) ->
            RoomJID = jid:make(<<Channel/binary, "%", Server/binary>>,
                               To#jid.server),
            Reason = translate:translate(Lang, <<"Join the IRC channel here.">>),
-           Body = iolist_to_binary(
-                    io_lib:format(
-                      translate:translate(
-                        Lang, <<"Join the IRC channel in this Jabber ID: ~s">>),
-                      [jid:to_string(RoomJID)])),
+           Body = str:format(
+                    translate:translate(
+                      Lang, <<"Join the IRC channel in this Jabber ID: ~s">>),
+                    [jid:to_string(RoomJID)]),
            Invite = #message{
                        body = xmpp:mk_text(Body, Lang),
                        sub_els = [#muc_user{
@@ -782,43 +779,37 @@ generate_connection_params_field(Lang, Server, Encoding,
                         Port;
                     true -> ?DEFAULT_IRC_PORT
                  end,
-    PortUsed =
-       iolist_to_binary(integer_to_list(PortUsedInt)),
+    PortUsed = integer_to_binary(PortUsedInt),
     PasswordUsed = case Password of
                     <<>> -> <<>>;
                     _ -> Password
                   end,
-    NumberString =
-       iolist_to_binary(integer_to_list(Number)),
+    NumberString = integer_to_binary(Number),
     [#xdata_field{var = <<"password", NumberString/binary>>,
                  type = 'text-single',
-                 label =  iolist_to_binary(
-                            io_lib:format(
-                              translate:translate(Lang, <<"Password ~b">>),
-                              [Number])),
+                 label = str:format(
+                           translate:translate(Lang, <<"Password ~b">>),
+                           [Number]),
                  values = [PasswordUsed]},
      #xdata_field{var = <<"port", NumberString/binary>>,
                  type = 'text-single',
-                 label = iolist_to_binary(
-                           io_lib:format(
-                             translate:translate(Lang, <<"Port ~b">>),
-                             [Number])),
+                 label = str:format(
+                           translate:translate(Lang, <<"Port ~b">>),
+                           [Number]),
                  values = [PortUsed]},
      #xdata_field{var = <<"encoding", NumberString/binary>>,
                  type = 'list-single',
-                 label = list_to_binary(
-                           io_lib:format(
-                             translate:translate(Lang, <<"Encoding for server ~b">>),
-                             [Number])),
+                 label = str:format(
+                           translate:translate(Lang, <<"Encoding for server ~b">>),
+                           [Number]),
                  values = [EncodingUsed],
                  options = [#xdata_option{label = E, value = E}
                             || E <- ?POSSIBLE_ENCODINGS]},
      #xdata_field{var = <<"server", NumberString/binary>>,
                  type = 'text-single',
-                 label = list_to_binary(
-                           io_lib:format(
-                             translate:translate(Lang, <<"Server ~b">>),
-                             [Number])),
+                 label = str:format(
+                           translate:translate(Lang, <<"Server ~b">>),
+                           [Number]),
                  values = [Server]}].
 
 parse_connections_params(#xdata{fields = Fields}) ->
index c9b460ad0b961c5e20a81fb421f7c6374fae89b0..2e604203cd5348ff0d38535f9a2bf7de2b2a1750 100644 (file)
@@ -1213,5 +1213,5 @@ unixtime2string(Unixtime) ->
                                                     {0, 0, 0}}),
     {{Year, Month, Day}, {Hour, Minute, Second}} =
        calendar:universal_time_to_local_time(calendar:gregorian_seconds_to_datetime(Secs)),
-    iolist_to_binary(io_lib:format("~4..0w-~2..0w-~2..0w ~2..0w:~2..0w:~2..0w",
+    (str:format("~4..0w-~2..0w-~2..0w ~2..0w:~2..0w:~2..0w",
                                   [Year, Month, Day, Hour, Minute, Second])).
index 5cf52e60f0e1d3ee48fe0284983efcd332dc5f66..2675db9b535aa8e5cde0639a76746786532791c9 100644 (file)
@@ -247,18 +247,18 @@ build_filename_string(TimeStamp, OutDir, RoomJID,
     {Dir, Filename, Rel} = case DirType of
                             subdirs ->
                                 SYear =
-                                    iolist_to_binary(io_lib:format("~4..0w",
+                                    (str:format("~4..0w",
                                                                    [Year])),
                                 SMonth =
-                                    iolist_to_binary(io_lib:format("~2..0w",
+                                    (str:format("~2..0w",
                                                                    [Month])),
-                                SDay = iolist_to_binary(io_lib:format("~2..0w",
+                                SDay = (str:format("~2..0w",
                                                                       [Day])),
                                 {fjoin([SYear, SMonth]), SDay,
                                  <<"../..">>};
                             plain ->
                                 Date =
-                                    iolist_to_binary(io_lib:format("~4..0w-~2..0w-~2..0w",
+                                    (str:format("~4..0w-~2..0w-~2..0w",
                                                                    [Year,
                                                                     Month,
                                                                     Day])),
@@ -727,7 +727,7 @@ fw(F, S, FileFormat) when is_atom(FileFormat) ->
     fw(F, S, [], FileFormat).
 
 fw(F, S, O, FileFormat) ->
-    S1 = list_to_binary(io_lib:format(binary_to_list(S) ++ "~n", O)),
+    S1 = (str:format(binary_to_list(S) ++ "~n", O)),
     S2 = case FileFormat of
             html ->
                 S1;
index f620e73c5052e01eeaf9de62d0934a4aad72363c..eedbcaeb17ec55dc10765323fb1d3f618e22de9f 100644 (file)
@@ -717,7 +717,7 @@ user_queue(User, Server, Query, Lang) ->
     Hdrs = get_messages_subset(US, Server, HdrsAll),
     FMsgs = format_user_queue(Hdrs),
     [?XC(<<"h1">>,
-        list_to_binary(io_lib:format(?T(<<"~s's Offline Messages Queue">>),
+        (str:format(?T(<<"~s's Offline Messages Queue">>),
                                       [us_to_list(US)])))]
       ++
       case Res of
@@ -801,7 +801,7 @@ webadmin_user(Acc, User, Server, Lang) ->
     QueueLen = count_offline_messages(jid:nodeprep(User),
                                jid:nameprep(Server)),
     FQueueLen = [?AC(<<"queue/">>,
-                    (iolist_to_binary(integer_to_list(QueueLen))))],
+                    (integer_to_binary(QueueLen)))],
     Acc ++
       [?XCT(<<"h3">>, <<"Offline Messages:">>)] ++
        FQueueLen ++
index c379760edb1d68f463009fde089d59711386ea5b..ba79cf7bcb5255a7c7e7f408d907498bd4fc8bf6 100644 (file)
@@ -3776,7 +3776,7 @@ err_unsupported_access_model() ->
 -spec uniqid() -> mod_pubsub:itemId().
 uniqid() ->
     {T1, T2, T3} = p1_time_compat:timestamp(),
-    iolist_to_binary(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])).
+    (str:format("~.16B~.16B~.16B", [T1, T2, T3])).
 
 -spec itemsEls([#pubsub_item{}]) -> [ps_item()].
 itemsEls(Items) ->
index dc8ca995c7f0767a28e78747ffc4f4b60a678c33..3cec0660b09acb9f03c1c7df45bc7b29aa12a621 100644 (file)
@@ -392,7 +392,7 @@ send_registration_notifications(Mod, UJID, Source) ->
         [] -> ok;
         JIDs when is_list(JIDs) ->
             Body =
-                iolist_to_binary(io_lib:format("[~s] The account ~s was registered from "
+                (str:format("[~s] The account ~s was registered from "
                                                "IP address ~s on node ~w using ~p.",
                                                [get_time_string(),
                                                 jid:to_string(UJID),
index 04ae55ae7aaa3e3722a5c93af9878dcb0c4c4308..06daf0810bbe1e613f2af97e3cdf16104b67782c 100644 (file)
@@ -299,7 +299,7 @@ add_record_route_and_set_uri(URI, LServer, #sip{hdrs = Hdrs} = Req) ->
            case need_record_route(LServer) of
                true ->
                    RR_URI = get_configured_record_route(LServer),
-                   TS = list_to_binary(integer_to_list(p1_time_compat:system_time(seconds))),
+                   TS = (integer_to_binary(p1_time_compat:system_time(seconds))),
                    Sign = make_sign(TS, Hdrs),
                    User = <<TS/binary, $-, Sign/binary>>,
                    NewRR_URI = RR_URI#uri{user = User},
@@ -339,7 +339,7 @@ make_sign(TS, Hdrs) ->
 is_signed_by_me(TS_Sign, Hdrs) ->
     try
        [TSBin, Sign] = str:tokens(TS_Sign, <<"-">>),
-       TS = list_to_integer(binary_to_list(TSBin)),
+       TS = (binary_to_integer(TSBin)),
        NowTS = p1_time_compat:system_time(seconds),
        true = (NowTS - TS) =< ?SIGN_LIFETIME,
        Sign == make_sign(TSBin, Hdrs)
index fcaa4236596b645d38b7243d19f8d5ef08546d14..e6532c934e17d6289098f0de8aac379a564f2559 100644 (file)
@@ -355,7 +355,7 @@ min_expires() ->
     60.
 
 to_integer(Bin, Min, Max) ->
-    case catch list_to_integer(binary_to_list(Bin)) of
+    case catch (binary_to_integer(Bin)) of
         N when N >= Min, N =< Max ->
             {ok, N};
         _ ->
index f146498c6fa7e33c3638a8feefea8b372daa46bb..e43409e0648e42420a7420c49ec875c978783e23 100644 (file)
@@ -111,7 +111,7 @@ get_local_stat(Server, [], Name)
       {'EXIT', _Reason} ->
          ?STATERR(500, <<"Internal Server Error">>);
       Users ->
-         ?STATVAL((iolist_to_binary(integer_to_list(length(Users)))),
+         ?STATVAL((integer_to_binary(length(Users))),
                   <<"users">>)
     end;
 get_local_stat(Server, [], Name)
@@ -122,13 +122,13 @@ get_local_stat(Server, [], Name)
       {'EXIT', _Reason} ->
          ?STATERR(500, <<"Internal Server Error">>);
       NUsers ->
-         ?STATVAL((iolist_to_binary(integer_to_list(NUsers))),
+         ?STATVAL((integer_to_binary(NUsers)),
                   <<"users">>)
     end;
 get_local_stat(_Server, [], Name)
     when Name == <<"users/all-hosts/online">> ->
     Users = ejabberd_sm:connected_users_number(),
-    ?STATVAL((iolist_to_binary(integer_to_list(Users))), <<"users">>);
+    ?STATVAL((integer_to_binary(Users)), <<"users">>);
 get_local_stat(_Server, [], Name)
     when Name == <<"users/all-hosts/total">> ->
     NumUsers = lists:foldl(fun (Host, Total) ->
@@ -136,7 +136,7 @@ get_local_stat(_Server, [], Name)
                                     + Total
                           end,
                           0, ?MYHOSTS),
-    ?STATVAL((iolist_to_binary(integer_to_list(NumUsers))),
+    ?STATVAL((integer_to_binary(NumUsers)),
             <<"users">>);
 get_local_stat(_Server, _, Name) ->
     ?STATERR(404, <<"Not Found">>).
@@ -149,9 +149,7 @@ get_node_stat(Node, Name)
       {badrpc, _Reason} ->
          ?STATERR(500, <<"Internal Server Error">>);
       CPUTime ->
-         ?STATVAL(list_to_binary(
-                     io_lib:format("~.3f",
-                                   [element(1, CPUTime) / 1000])),
+           ?STATVAL(str:format("~.3f", [element(1, CPUTime) / 1000]),
                   <<"seconds">>)
     end;
 get_node_stat(Node, Name)
@@ -161,9 +159,7 @@ get_node_stat(Node, Name)
       {badrpc, _Reason} ->
          ?STATERR(500, <<"Internal Server Error">>);
       RunTime ->
-         ?STATVAL(list_to_binary(
-                     io_lib:format("~.3f",
-                                   [element(1, RunTime) / 1000])),
+         ?STATVAL(str:format("~.3f", [element(1, RunTime) / 1000]),
                   <<"seconds">>)
     end;
 get_node_stat(Node, Name)
@@ -174,7 +170,7 @@ get_node_stat(Node, Name)
       {badrpc, _Reason} ->
          ?STATERR(500, <<"Internal Server Error">>);
       Users ->
-         ?STATVAL((iolist_to_binary(integer_to_list(length(Users)))),
+         ?STATVAL((integer_to_binary(length(Users))),
                   <<"users">>)
     end;
 get_node_stat(Node, Name)
@@ -185,7 +181,7 @@ get_node_stat(Node, Name)
       {badrpc, _Reason} ->
          ?STATERR(500, <<"Internal Server Error">>);
       Transactions ->
-         ?STATVAL((iolist_to_binary(integer_to_list(Transactions))),
+         ?STATVAL((integer_to_binary(Transactions)),
                   <<"transactions">>)
     end;
 get_node_stat(Node, Name)
@@ -196,7 +192,7 @@ get_node_stat(Node, Name)
       {badrpc, _Reason} ->
          ?STATERR(500, <<"Internal Server Error">>);
       Transactions ->
-         ?STATVAL((iolist_to_binary(integer_to_list(Transactions))),
+         ?STATVAL((integer_to_binary(Transactions)),
                   <<"transactions">>)
     end;
 get_node_stat(Node, Name)
@@ -207,7 +203,7 @@ get_node_stat(Node, Name)
       {badrpc, _Reason} ->
          ?STATERR(500, <<"Internal Server Error">>);
       Transactions ->
-         ?STATVAL((iolist_to_binary(integer_to_list(Transactions))),
+         ?STATVAL((integer_to_binary(Transactions)),
                   <<"transactions">>)
     end;
 get_node_stat(Node, Name)
@@ -218,7 +214,7 @@ get_node_stat(Node, Name)
       {badrpc, _Reason} ->
          ?STATERR(500, <<"Internal Server Error">>);
       Transactions ->
-         ?STATVAL((iolist_to_binary(integer_to_list(Transactions))),
+         ?STATVAL((integer_to_binary(Transactions)),
                   <<"transactions">>)
     end;
 get_node_stat(_, Name) ->
index 80b22554d7d16112bead2beb7167837fad92cc4a..36bf796ee2a90ad30db5d125f07461593bdda68a 100644 (file)
@@ -70,7 +70,7 @@ get_os() ->
     OSType = list_to_binary([atom_to_list(Osfamily), $/, atom_to_list(Osname)]),
     OSVersion = case os:version() of
                  {Major, Minor, Release} ->
-                     iolist_to_binary(io_lib:format("~w.~w.~w",
+                     (str:format("~w.~w.~w",
                                                     [Major, Minor, Release]));
                  VersionString -> VersionString
                end,
index 713d33970317808a7d4ea450b4f762be10fc6b84..986a0b9b274e4f42e08e2e195ded6f4ff37424cd 100644 (file)
@@ -127,7 +127,7 @@ subscription_opt_to_sql({subscription_depth, Depth}) ->
            N -> integer_to_sql(N)
        end}.
 
-integer_to_sql(N) -> iolist_to_binary(integer_to_list(N)).
+integer_to_sql(N) -> integer_to_binary(N).
 
 boolean_to_sql(true) -> <<"1">>;
 boolean_to_sql(false) -> <<"0">>.
index 297c6627c6739b2aa97105d7069d45d75a9ea847..b6986b69d20de6a6ecefa6e0ec881d60851cddc0 100644 (file)
@@ -170,7 +170,7 @@ write_subscription(_JID, _NodeId, SubID, Options) ->
 -spec make_subid() -> SubId::mod_pubsub:subId().
 make_subid() ->
     {T1, T2, T3} = p1_time_compat:timestamp(),
-    iolist_to_binary(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])).
+    (str:format("~.16B~.16B~.16B", [T1, T2, T3])).
 
 %%
 %% Subscription XForm processing.
@@ -207,14 +207,14 @@ val_xfield(digest_frequency = Opt, [Val]) ->
        N when is_integer(N) -> N;
        _ ->
            Txt = <<"Value of '~s' should be integer">>,
-           ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
+           ErrTxt = (str:format(Txt, [Opt])),
            {error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
     end;
 val_xfield(expire = Opt, [Val]) ->
     try xmpp_util:decode_timestamp(Val)
     catch _:{bad_timestamp, _} ->
            Txt = <<"Value of '~s' should be datetime string">>,
-           ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
+           ErrTxt = (str:format(Txt, [Opt])),
            {error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
     end;
 val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val);
@@ -227,7 +227,7 @@ val_xfield(subscription_depth = Opt, [Depth]) ->
        N when is_integer(N) -> N;
        _ ->
            Txt = <<"Value of '~s' should be integer">>,
-           ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
+           ErrTxt = (str:format(Txt, [Opt])),
            {error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
     end.
 
@@ -238,7 +238,7 @@ xopt_to_bool(_, <<"false">>) -> false;
 xopt_to_bool(_, <<"true">>) -> true;
 xopt_to_bool(Option, _) ->
     Txt = <<"Value of '~s' should be boolean">>,
-    ErrTxt = iolist_to_binary(io_lib:format(Txt, [Option])),
+    ErrTxt = (str:format(Txt, [Option])),
     {error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}.
 
 %% Return a field for an XForm for Key, with data filled in, if
@@ -311,7 +311,7 @@ xfield_label(subscription_depth) -> ?SUBSCRIPTION_DEPTH_LABEL.
 xfield_val(deliver, Val) -> [bool_to_xopt(Val)];
 %xfield_val(digest, Val) -> [bool_to_xopt(Val)];
 %xfield_val(digest_frequency, Val) ->
-%    [iolist_to_binary(integer_to_list(Val))];
+%    [integer_to_binary(Val))];
 %xfield_val(expire, Val) ->
 %    [jlib:now_to_utc_string(Val)];
 %xfield_val(include_body, Val) -> [bool_to_xopt(Val)];
@@ -320,7 +320,7 @@ xfield_val(subscription_type, items) -> [<<"items">>];
 xfield_val(subscription_type, nodes) -> [<<"nodes">>];
 xfield_val(subscription_depth, all) -> [<<"all">>];
 xfield_val(subscription_depth, N) ->
-    [iolist_to_binary(integer_to_list(N))].
+    [integer_to_binary(N)].
 
 
 bool_to_xopt(true) -> <<"true">>;
index bb7b6411241ef8e16679f3403c70ad5d89229792..da72cc96ee6cd73c8b2c69337e28eb2a95af8d8b 100644 (file)
@@ -135,7 +135,7 @@ create_table() -> ok.
 -spec make_subid() -> mod_pubsub:subId().
 make_subid() ->
     {T1, T2, T3} = p1_time_compat:timestamp(),
-    iolist_to_binary(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])).
+    (str:format("~.16B~.16B~.16B", [T1, T2, T3])).
 
 %%
 %% Subscription XForm processing.
@@ -172,14 +172,14 @@ val_xfield(digest_frequency = Opt, [Val]) ->
        N when is_integer(N) -> N;
        _ ->
            Txt = <<"Value of '~s' should be integer">>,
-           ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
+           ErrTxt = (str:format(Txt, [Opt])),
            {error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
     end;
 val_xfield(expire = Opt, [Val]) ->
     try xmpp_util:decode_timestamp(Val)
     catch _:{bad_timestamp, _} ->
            Txt = <<"Value of '~s' should be datetime string">>,
-           ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
+           ErrTxt = (str:format(Txt, [Opt])),
            {error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
     end;
 val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val);
@@ -192,7 +192,7 @@ val_xfield(subscription_depth = Opt, [Depth]) ->
        N when is_integer(N) -> N;
        _ ->
            Txt = <<"Value of '~s' should be integer">>,
-           ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
+           ErrTxt = (str:format(Txt, [Opt])),
            {error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
     end.
 
@@ -203,7 +203,7 @@ xopt_to_bool(_, <<"false">>) -> false;
 xopt_to_bool(_, <<"true">>) -> true;
 xopt_to_bool(Option, _) ->
     Txt = <<"Value of '~s' should be boolean">>,
-    ErrTxt = iolist_to_binary(io_lib:format(Txt, [Option])),
+    ErrTxt = (str:format(Txt, [Option])),
     {error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}.
 
 %% Return a field for an XForm for Key, with data filled in, if
@@ -276,7 +276,7 @@ xfield_label(subscription_depth) -> ?SUBSCRIPTION_DEPTH_LABEL.
 xfield_val(deliver, Val) -> [bool_to_xopt(Val)];
 %xfield_val(digest, Val) -> [bool_to_xopt(Val)];
 %xfield_val(digest_frequency, Val) ->
-%    [iolist_to_binary(integer_to_list(Val))];
+%    [integer_to_binary(Val))];
 %xfield_val(expire, Val) ->
 %    [jlib:now_to_utc_string(Val)];
 %xfield_val(include_body, Val) -> [bool_to_xopt(Val)];
@@ -285,7 +285,7 @@ xfield_val(subscription_type, items) -> [<<"items">>];
 xfield_val(subscription_type, nodes) -> [<<"nodes">>];
 xfield_val(subscription_depth, all) -> [<<"all">>];
 xfield_val(subscription_depth, N) ->
-    [iolist_to_binary(integer_to_list(N))].
+    [integer_to_binary(N)].
 
 bool_to_xopt(false) -> <<"false">>;
 bool_to_xopt(true) -> <<"true">>.