improve script to find classes where making the class hidden

will provide the biggest benefit

Change-Id: I78ae044612ae1fea7496db1b420848f43e552504
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164723
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2024-03-12 21:31:31 +01:00
parent 44a819a466
commit 1b9a3894ee
3 changed files with 8583 additions and 3975 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+30
View File
@@ -128,6 +128,36 @@ print("unused_exports = " + str(len(unused_exports)))
# if i == -1: return sym
# return sym[:i]
# for each class, count how many symbols will become hidden if we mark the class as hidden
can_be_hidden_count = dict()
for sym in exported_symbols2:
i = sym.rfind("::")
if i == -1: continue
clz = sym[:i]
if clz in can_be_hidden_count:
can_be_hidden_count[clz] = can_be_hidden_count[clz] + 1
else:
can_be_hidden_count[clz] = 1
for sym in imported_symbols2:
i = sym.rfind("::")
if i == -1: continue
clz = sym[:i]
if clz in can_be_hidden_count:
can_be_hidden_count[clz] = can_be_hidden_count[clz] - 1
else:
can_be_hidden_count[clz] = -1
# convert to list, and sort the results in descending order
can_be_hidden_list = list()
for clz in can_be_hidden_count:
cnt = can_be_hidden_count[clz]
if cnt > 0:
can_be_hidden_list.append((cnt, clz))
can_be_hidden_list.sort(reverse=True)
with open("bin/find-can-be-private-symbols.classes.results", "wt") as f:
for i in can_be_hidden_list:
f.write(str(i[0]) + " " + i[1] + "\n")
with open("bin/find-can-be-private-symbols.functions.results", "wt") as f:
for sym in sorted(unused_exports):
# Filter out most of the noise.