From efdc7a774406e51cdd729a70341f97e81923f9df Mon Sep 17 00:00:00 2001 From: Evan Czaplicki Date: Thu, 13 Feb 2014 09:29:51 +0100 Subject: [PATCH] Start using strict mode for everything MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit V8 engineer said it is always faster, so that’s probably reliable info :) --- Setup.hs | 3 ++- compiler/Generate/JavaScript.hs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Setup.hs b/Setup.hs index 6931b9a..b9e096e 100644 --- a/Setup.hs +++ b/Setup.hs @@ -148,7 +148,8 @@ buildRuntime :: LocalBuildInfo -> [FilePath] -> IO () buildRuntime lbi elmos = do createDirectoryIfMissing True (rtsDir lbi) let rts' = rts lbi - writeFile rts' "var Elm = {}; Elm.Native = {}; Elm.Native.Graphics = {};\n\ + writeFile rts' "'use strict';\n\ + \var Elm = {}; Elm.Native = {}; Elm.Native.Graphics = {};\n\ \var ElmRuntime = {}; ElmRuntime.Render = {};\n" mapM_ (appendTo rts') =<< getFiles ".js" "libraries" mapM_ (appendTo rts') elmos diff --git a/compiler/Generate/JavaScript.hs b/compiler/Generate/JavaScript.hs index 182cc6f..15f1a96 100644 --- a/compiler/Generate/JavaScript.hs +++ b/compiler/Generate/JavaScript.hs @@ -293,7 +293,8 @@ generate unsafeModule = thisModule = dotSep ("_elm" : names modul ++ ["values"]) programStmts = concat - [ setup (Just "_elm") (names modul ++ ["values"]) + [ [ ExprStmt () $ string "use strict" ] + , setup (Just "_elm") (names modul ++ ["values"]) , [ IfSingleStmt () thisModule (ret thisModule) ] , [ internalImports (List.intercalate "." (names modul)) ] , concatMap jsImport . Set.toList . Set.fromList . map fst $ imports modul