fcl-md: need to rewrite HtmlEscape / UrlEscape

markdown.utils.pas:

function HtmlEscape(const S: String): String;

var
  C : char;

begin
  Result:='';
  for C in S do
    Result:=Result+HtmlEscape(C);
end;

and this

function UrlEscape(const S: String): String;

var
  C : UnicodeChar;

begin
  Result:='';
  for C in ToUnicodeChars(S) do
    Result:=Result+urlEscape(C);
end;

very unoptimal. too many reallocs. may affect the speed of markdown parsing?

best is to parse S, calculate the resulting len, allocate resulting str only once, and then parse S again and fill the result. usual tactic.

Edited by Alexey Torgashin