summaryrefslogtreecommitdiff
path: root/src/mono_opt.sml
diff options
context:
space:
mode:
Diffstat (limited to 'src/mono_opt.sml')
-rw-r--r--src/mono_opt.sml33
1 files changed, 18 insertions, 15 deletions
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))