Mercurial > urweb
changeset 1764:e8c668e518fb
Speed up space eating in MonoOpt
author | Vladimir Shabanov <vshabanoff@gmail.com> |
---|---|
date | Thu, 17 May 2012 01:41:30 +0400 |
parents | 22858505bb2d |
children | be114e170b77 |
files | src/mono_opt.sml |
diffstat | 1 files changed, 18 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/mono_opt.sml Wed May 16 22:46:35 2012 +0400 +++ b/src/mono_opt.sml Thu May 17 01:41:30 2012 +0400 @@ -143,21 +143,24 @@ fun exp e = case e of EPrim (Prim.String s) => - let - val (_, chs) = - CharVector.foldl (fn (ch, (lastSpace, chs)) => - let - val isSpace = Char.isSpace ch - in - if isSpace andalso lastSpace then - (true, chs) - else - (isSpace, ch :: chs) - end) - (false, []) s - in - EPrim (Prim.String (String.implode (rev chs))) - end + if CharVector.exists Char.isSpace s then + let + val (_, chs) = + CharVector.foldl (fn (ch, (lastSpace, chs)) => + let + val isSpace = Char.isSpace ch + in + if isSpace andalso lastSpace then + (true, chs) + else + (isSpace, ch :: chs) + end) + (false, []) s + in + EPrim (Prim.String (String.implode (rev chs))) + end + else + e | EFfiApp ("Basis", "strcat", [(e1, _), (e2, _)]) => exp (EStrcat (e1, e2))