Builtin source should be minified more
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Dec 2015 17:30:49 +0000 (17:30 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Dec 2015 17:30:49 +0000 (17:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152290

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-12-16
Reviewed by Darin Adler.

* Scripts/builtins/builtins_model.py:
(BuiltinFunction.fromString):
Remove primarily empty lines that would just introduce clutter.
We only do the minification in non-Debug configurations, which
is determined by the CONFIGURATION environment variable. You can
see how tests would generate differently, like so:
shell> CONFIGURATION=Release ./Tools/Scripts/run-builtins-generator-tests

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194144 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/Scripts/builtins/builtins_model.py [changed mode: 0644->0755]

index ace5017..74a1681 100644 (file)
@@ -1,3 +1,18 @@
+2015-12-16  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Builtin source should be minified more
+        https://bugs.webkit.org/show_bug.cgi?id=152290
+
+        Reviewed by Darin Adler.
+
+        * Scripts/builtins/builtins_model.py:
+        (BuiltinFunction.fromString):
+        Remove primarily empty lines that would just introduce clutter.
+        We only do the minification in non-Debug configurations, which
+        is determined by the CONFIGURATION environment variable. You can
+        see how tests would generate differently, like so:
+        shell> CONFIGURATION=Release ./Tools/Scripts/run-builtins-generator-tests
+
 2015-12-16  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r194135.
old mode 100644 (file)
new mode 100755 (executable)
index d765eca..cdd5f90
@@ -49,6 +49,9 @@ multilineCommentRegExp = re.compile(r"\/\*.*?\*\/", re.MULTILINE | re.S)
 singleLineCommentRegExp = re.compile(r"\/\/.*?\n", re.MULTILINE | re.S)
 keyValueAnnotationCommentRegExp = re.compile(r"^\/\/ @(\w+)=([^=]+?)\n", re.MULTILINE | re.S)
 flagAnnotationCommentRegExp = re.compile(r"^\/\/ @(\w+)[^=]*?\n", re.MULTILINE | re.S)
+lineWithOnlySingleLineCommentRegExp = re.compile(r"^\s*\/\/\n", re.MULTILINE | re.S)
+lineWithTrailingSingleLineCommentRegExp = re.compile(r"\s*\/\/\n", re.MULTILINE | re.S)
+multipleEmptyLinesRegExp = re.compile(r"\n{2,}", re.MULTILINE | re.S)
 
 class ParseException(Exception):
     pass
@@ -100,6 +103,11 @@ class BuiltinFunction:
     @staticmethod
     def fromString(function_string):
         function_source = multilineCommentRegExp.sub("", function_string)
+        if os.getenv("CONFIGURATION", "Debug").startswith("Debug"):
+            function_source = lineWithOnlySingleLineCommentRegExp.sub("", function_source)
+            function_source = lineWithTrailingSingleLineCommentRegExp.sub("\n", function_source)
+            function_source = multipleEmptyLinesRegExp.sub("\n", function_source)
+
         function_name = functionNameRegExp.findall(function_source)[0]
         is_constructor = functionIsConstructorRegExp.match(function_source) != None
         parameters = [s.strip() for s in functionParameterFinder.findall(function_source)[0].split(',')]