aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2020-11-12 19:44:26 +0100
committerGravatar Numerlor <[email protected]>2020-11-15 03:12:04 +0100
commit2bae8eeed0eae75d782da097e78826650e1ac498 (patch)
tree9c156badeab42343077d6e08080b037db77514cd
parentCancel scheduled inventory updates on all refreshes (diff)
Intern relative url paths
Group name interning was also moved to the DocItem creation to group the behaviour
Diffstat (limited to '')
-rw-r--r--bot/exts/info/doc/_cog.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/bot/exts/info/doc/_cog.py b/bot/exts/info/doc/_cog.py
index 822f682bf..ecc648d89 100644
--- a/bot/exts/info/doc/_cog.py
+++ b/bot/exts/info/doc/_cog.py
@@ -218,10 +218,8 @@ class DocCog(commands.Cog):
for symbol, relative_doc_url in items:
if "/" in symbol:
continue # skip unreachable symbols with slashes
- # Intern the group names since they're reused in all the DocItems
- # to remove unnecessary memory consumption from them being unique objects
- group_name = sys.intern(group.split(":")[1])
+ group_name = group.split(":")[1]
if (original_symbol := self.doc_symbols.get(symbol)) is not None:
if group_name in FORCE_PREFIX_GROUPS:
symbol = f"{group_name}.{symbol}"
@@ -240,7 +238,14 @@ class DocCog(commands.Cog):
self.renamed_symbols.add(symbol)
relative_url_path, _, symbol_id = relative_doc_url.partition("#")
- symbol_item = DocItem(api_package_name, group_name, base_url, relative_url_path, symbol_id)
+ # Intern fields that have shared content so we're not storing unique strings for every object
+ symbol_item = DocItem(
+ api_package_name,
+ sys.intern(group_name),
+ base_url,
+ sys.intern(relative_url_path),
+ symbol_id
+ )
self.doc_symbols[symbol] = symbol_item
self.item_fetcher.add_item(symbol_item)