maybe dont replace things when auto replace is disabled

This commit is contained in:
bleck9999 2021-08-30 19:04:45 +01:00
parent 42fa0903e7
commit 80ee915bfd
No known key found for this signature in database
GPG Key ID: D0CA0C41DB616843
1 changed files with 3 additions and 3 deletions

View File

@ -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)")