Skip to content

Commit

Permalink
Use maximum zlib compression when generating editor translation headers
Browse files Browse the repository at this point in the history
With comments stripped, this reduces the combined generated translation
size from 28.7 MB to 28.4 MB (-240 KB).
  • Loading branch information
Calinou committed Oct 29, 2021
1 parent dae626a commit 89cf17c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion core/core_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def make_certs_header(target, source, env):
decomp_size = len(buf)
import zlib

buf = zlib.compress(buf)
# Use maximum zlib compression level to further reduce file size
# (at the cost of initial build times).
buf = zlib.compress(buf, zlib.Z_BEST_COMPRESSION)

g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef CERTS_COMPRESSED_GEN_H\n")
Expand Down
8 changes: 6 additions & 2 deletions editor/editor_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def make_doc_header(target, source, env):
decomp_size = len(buf)
import zlib

buf = zlib.compress(buf)
# Use maximum zlib compression level to further reduce file size
# (at the cost of initial build times).
buf = zlib.compress(buf, zlib.Z_BEST_COMPRESSION)

g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
g.write("#ifndef _DOC_DATA_RAW_H\n")
Expand Down Expand Up @@ -92,7 +94,9 @@ def make_translations_header(target, source, env, category):
with open(sorted_paths[i], "rb") as f:
buf = f.read()
decomp_size = len(buf)
buf = zlib.compress(buf)
# Use maximum zlib compression level to further reduce file size
# (at the cost of initial build times).
buf = zlib.compress(buf, zlib.Z_BEST_COMPRESSION)
name = os.path.splitext(os.path.basename(sorted_paths[i]))[0]

g.write("static const unsigned char _{}_translation_{}_compressed[] = {{\n".format(category, name))
Expand Down
4 changes: 3 additions & 1 deletion modules/mono/build_scripts/make_android_mono_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ def generate_compressed_config(config_src, output_dir):
decompr_size = len(buf)
import zlib

buf = zlib.compress(buf)
# Use maximum zlib compression level to further reduce file size
# (at the cost of initial build times).
buf = zlib.compress(buf, zlib.Z_BEST_COMPRESSION)
compr_size = len(buf)

bytes_seq_str = ""
Expand Down

0 comments on commit 89cf17c

Please sign in to comment.