More efficient implementation of hex_to_upper

This commit is contained in:
Gavin M. Roy 2016-10-27 13:14:50 -04:00
parent bcc245b2a9
commit 72a8a66488
2 changed files with 4 additions and 4 deletions

View file

@ -1,6 +1,6 @@
{application, urilib, [
{description, "A RFC-3986 URI Library for parsing and building URIs"},
{vsn,"0.2.0"},
{vsn,"0.3.0"},
{licenses, ["BSD"]},
{links, [{"Github", "https://github.com/gmr/urilib"}]},
{maintainers, ["Gavin M. Roy"]},

View file

@ -323,11 +323,11 @@ url_maybe_add_fragment(Value, URL) ->
hex_to_upper(Value) ->
hex_to_upper(Value, []).
hex_to_upper([], Accum) ->
Accum;
lists:reverse(Accum);
hex_to_upper([$%, B1, B2|T], Accum) ->
hex_to_upper(T, lists:append(Accum, [$%, to_upper(B1), to_upper(B2)]));
hex_to_upper(T, [to_upper(B2), to_upper(B1), $% | Accum]);
hex_to_upper([H|T], Accum) ->
hex_to_upper(T, lists:append(Accum, [H])).
hex_to_upper(T, [H | Accum]).
-spec to_upper(char()) -> char().