From 4aeb721c42f6e7f52ff27b2a9b54b93e27f600ad Mon Sep 17 00:00:00 2001 From: Vladimir Shabanov Date: Thu, 17 May 2012 01:41:30 +0400 Subject: Speed up space eating in MonoOpt --- src/mono_opt.sml | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'src/mono_opt.sml') diff --git a/src/mono_opt.sml b/src/mono_opt.sml index 17d23cc2..70404c09 100644 --- a/src/mono_opt.sml +++ b/src/mono_opt.sml @@ -143,21 +143,24 @@ fun checkProperty s = size s > 0 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)) -- cgit v1.2.3