summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Vladimir Shabanov <vshabanoff@gmail.com>2012-05-17 01:41:30 +0400
committerGravatar Vladimir Shabanov <vshabanoff@gmail.com>2012-05-17 01:41:30 +0400
commit2cdddca707fe94e9534cb2929aac46970f1f7e0c (patch)
tree69e35cdb07513fe171381f55f1dd6141cd8557b6 /src
parentcfa495696d87fb15d860a0d06881c11557785647 (diff)
Speed up space eating in MonoOpt
Diffstat (limited to 'src')
-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))