From 7eadf111456d1ba8587458e0c3e167ef7503d466 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 16 Feb 2013 23:17:17 -0800 Subject: [PATCH] Optimize the ES6 template delimiter regexp and regexp to detect strings. Former-commit-id: 6177f2b32f27515cf8edcac6036d0adb58ebfcd0 --- build.js | 2 +- build/pre-compile.js | 2 +- lodash.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.js b/build.js index cd1cfe9a0..c6f540df4 100755 --- a/build.js +++ b/build.js @@ -2413,8 +2413,8 @@ }); } else if (!isStdOut) { - outputUsed = true; filePath = outputPath || path.join(cwd, basename + '.js'); + outputUsed = true; callback({ 'source': debugSource, 'outputPath': filePath diff --git a/build/pre-compile.js b/build/pre-compile.js index 5db74035d..020801c5d 100644 --- a/build/pre-compile.js +++ b/build/pre-compile.js @@ -233,7 +233,7 @@ source = source.replace("result[length]['value']", 'result[length].value'); // remove whitespace from string literals - source = source.replace(/^([ "'\w]+:)? *"(?:(?=(\\?))\2.)*?"|'(?:(?=(\\?))\3.)*?'/gm, function(string, captured) { + source = source.replace(/^([ "'\w]+:)? *"[^"\\\n]*(?:\\.[^"\\\n]*)*"|'[^'\\\n]*(?:\\.[^'\\\n]*)*'/gm, function(string, captured) { // remove object literal property name if (/:$/.test(captured)) { string = string.slice(captured.length); diff --git a/lodash.js b/lodash.js index 03c6002ce..ba6dec420 100644 --- a/lodash.js +++ b/lodash.js @@ -55,7 +55,7 @@ * Used to match ES6 template delimiters * http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.8.6 */ - var reEsTemplate = /\$\{((?:(?=\\?)\\?[\s\S])*?)\}/g; + var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; /** Used to match "interpolate" template delimiters */ var reInterpolate = /<%=([\s\S]+?)%>/g;