From 7e64bb4c3f6ec1efc04034b277de5d1d857e79fd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 3 Dec 2017 14:31:00 +0100 Subject: [PATCH] css: strip trailing comments in postprocess.py. Could get me back under 9 kB. --- css/postprocess.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/css/postprocess.py b/css/postprocess.py index 555076f9..9ff78106 100755 --- a/css/postprocess.py +++ b/css/postprocess.py @@ -129,7 +129,12 @@ def postprocess(files): if in_variable_declarations: out.write(":root {\n") not_just_variable_declarations = True - out.write(line) + + # Strip the trailing comment, if there, to save some bytes + if line.rstrip().endswith('*/'): + out.write(line[:line.rindex('/*')]) + else: + out.write(line) # Now open the imported files and replace variables for file in imported_files + files[1:]: @@ -163,8 +168,12 @@ def postprocess(files): in_comment = True continue - # Something else, copy verbatim to the output - out.write(line) + # Something else, copy verbatim to the output. Strip the + # trailing comment, if there, to save some bytes + if line.rstrip().endswith('*/'): + out.write(line[:line.rindex('/*')].rstrip() + '\n') + else: + out.write(line) return 0 -- 2.30.2