From 80ee915bfd965256f155bddcf0fee7b03b25d34f Mon Sep 17 00:00:00 2001 From: bleck9999 <55853712+bleck9999@users.noreply.github.com> Date: Mon, 30 Aug 2021 19:04:45 +0100 Subject: [PATCH] maybe dont replace things when auto replace is disabled --- ts-minifier.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ts-minifier.py b/ts-minifier.py index 28f3676..920f563 100644 --- a/ts-minifier.py +++ b/ts-minifier.py @@ -1,6 +1,6 @@ # Copyright (c) 2021 bleck9999 # https://github.com/bleck9999/ts-minifier -# Version: c9aef4d4 +# Version: b201eb4d import argparse import itertools @@ -243,7 +243,7 @@ def minify(script: Code, userobjects, usages): savings = uses*len(func) - (len(func)+len(minName)+2) if (verbose and savings <= 0) or (not auto_replace and savings > 0): print(f"Not aliasing standard library function {func} (would save {savings} bytes)") - else: + elif auto_replace and savings > 0: if verbose: print(f"Aliasing standard library function {func} to {minName} (saving {savings} bytes)") diff = len(func) - len(minName) @@ -277,7 +277,7 @@ def minify(script: Code, userobjects, usages): savings = uses * len(string) - (len(string) + len(minName) + 2) if (verbose and savings <= 0) or (not auto_replace and savings > 0): print(f"Not introducing variable for string {string} reused {uses} times (would save {savings} bytes)") - else: + elif auto_replace and savings > 0: # "duplicated code fragment" do i look like i give a shit if verbose: print(f"Introducing variable {minName} with value {string} (saving {savings} bytes)")