Commit 6e174eb8 authored by marcin's avatar marcin Committed by Commit Bot

Remove initial whitespace & empty lines to decrease JS files size

Patch will decrease size of JS files included into Chrome APK
(about 11 KB now)

Bug: 
Change-Id: I701c9904fbf22fd295199f255601dea6524a3766
Reviewed-on: https://chromium-review.googlesource.com/821071Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Marcin Wiącek <marcin@mwiacek.com>
Cr-Commit-Position: refs/heads/master@{#50179}
parent c3dda0bb
......@@ -96,6 +96,7 @@ Luis Reis <luis.m.reis@gmail.com>
Luke Zarko <lukezarko@gmail.com>
Maciej Małecki <me@mmalecki.com>
Marcin Cieślak <saper@marcincieslak.com>
Marcin Wiącek <marcin@mwiacek.com>
Mateusz Czeladka <mateusz.szczap@gmail.com>
Mathias Bynens <mathias@qiwi.be>
Matt Hanselman <mjhanselman@gmail.com>
......
......@@ -50,10 +50,12 @@ def ToCArray(byte_sequence):
return textwrap.fill(joined, 80)
def RemoveCommentsAndTrailingWhitespace(lines):
def RemoveCommentsEmptyLinesAndWhitespace(lines):
lines = re.sub(r'\n+', '\n', lines) # empty lines
lines = re.sub(r'//.*\n', '\n', lines) # end-of-line comments
lines = re.sub(re.compile(r'/\*.*?\*/', re.DOTALL), '', lines) # comments.
lines = re.sub(r'\s+\n+', '\n', lines) # trailing whitespace
lines = re.sub(r'\s+\n', '\n', lines) # trailing whitespace
lines = re.sub(r'\n\s+', '\n', lines) # initial whitespace
return lines
......@@ -342,7 +344,7 @@ def BuildFilterChain(macro_filename, message_template_file):
filter_chain.append(lambda l: ExpandConstants(l, message_templates))
filter_chain.extend([
RemoveCommentsAndTrailingWhitespace,
RemoveCommentsEmptyLinesAndWhitespace,
ExpandInlineMacros,
ExpandInlineConstants,
Validate,
......@@ -355,7 +357,7 @@ def BuildFilterChain(macro_filename, message_template_file):
return reduce(chain, filter_chain)
def BuildExtraFilterChain():
return lambda x: RemoveCommentsAndTrailingWhitespace(Validate(x))
return lambda x: RemoveCommentsEmptyLinesAndWhitespace(Validate(x))
class Sources:
def __init__(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment