From 72a8a66488f2f7f0c17a5b4119fb78852089573f Mon Sep 17 00:00:00 2001 From: "Gavin M. Roy" Date: Thu, 27 Oct 2016 13:14:50 -0400 Subject: [PATCH] More efficient implementation of hex_to_upper --- src/urilib.app.src | 2 +- src/urilib.erl | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/urilib.app.src b/src/urilib.app.src index 59b3bad..5d0bd49 100644 --- a/src/urilib.app.src +++ b/src/urilib.app.src @@ -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"]}, diff --git a/src/urilib.erl b/src/urilib.erl index b579ad9..755cc93 100644 --- a/src/urilib.erl +++ b/src/urilib.erl @@ -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().