diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2019-08-10 18:55:45 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-09-10 11:14:38 +0200 |
commit | 572ed87ee9eb3653f7509347d82e64f278a9ec06 (patch) | |
tree | 336bff3b69dcea947b85e23d9160e16062b8523d | |
parent | 641a0d02a32a7a2951ebfb970bf387f089681285 (diff) | |
download | pylint-git-572ed87ee9eb3653f7509347d82e64f278a9ec06.tar.gz |
[pylint.message] Optimize MessageDefinitionStore storage
-rw-r--r-- | pylint/message/message_definition_store.py | 11 | ||||
-rw-r--r-- | pylint/message/message_handler_mix_in.py | 3 | ||||
-rw-r--r-- | pylint/message/message_id_store.py | 4 |
3 files changed, 10 insertions, 8 deletions
diff --git a/pylint/message/message_definition_store.py b/pylint/message/message_definition_store.py index c233979a6..1439b032c 100644 --- a/pylint/message/message_definition_store.py +++ b/pylint/message/message_definition_store.py @@ -23,10 +23,6 @@ class MessageDefinitionStore: # It contains the 1:1 mapping from msgid to MessageDefinition. # Keys are msgid, values are MessageDefinition self._messages_definitions = {} - # Secondary registry for all old names kept for compatibility reasons - # May contain identical values under different MessageId - # (ie a MessageDefinition was renamed more than once) - self._old_message_definitions = {} # MessageDefinition kept by category self._msgs_by_category = collections.defaultdict(list) @@ -51,11 +47,12 @@ class MessageDefinitionStore: """ self.message_id_store.register_message_definition(message) self._messages_definitions[message.msgid] = message - self._old_message_definitions[message.msgid] = message - for old_msgid, _ in message.old_names: - self._old_message_definitions[old_msgid] = message self._msgs_by_category[message.msgid[0]].append(message.msgid) + @property + def msgids(self): + return self.message_id_store.msgids + def get_message_definitions(self, msgid_or_symbol: str) -> list: """Returns the Message object for this message. :param str msgid_or_symbol: msgid_or_symbol may be either a numeric or symbolic id. diff --git a/pylint/message/message_handler_mix_in.py b/pylint/message/message_handler_mix_in.py index ad8a11f45..5a7482951 100644 --- a/pylint/message/message_handler_mix_in.py +++ b/pylint/message/message_handler_mix_in.py @@ -106,8 +106,9 @@ class MessagesHandlerMixIn: # msgid is a checker name? if msgid.lower() in self._checkers: for checker in self._checkers[msgid.lower()]: + msgids = self.msgs_store.msgids for _msgid in checker.msgs: - if _msgid in self.msgs_store._old_message_definitions: + if _msgid in msgids: self._set_msg_status(_msgid, enable, scope, line) return diff --git a/pylint/message/message_id_store.py b/pylint/message/message_id_store.py index 756888a4b..2cf970aec 100644 --- a/pylint/message/message_id_store.py +++ b/pylint/message/message_id_store.py @@ -33,6 +33,10 @@ class MessageIdStore: def get_msgid(self, symbol: str) -> str: return self.__symbol_to_msgid[symbol] + @property + def msgids(self): + return list(self.__msgid_to_symbol.keys()) + list(self.__old_names.keys()) + def register_message_definition(self, message_definition): self.check_msgid_and_symbol(message_definition.msgid, message_definition.symbol) self.add_msgid_and_symbol(message_definition.msgid, message_definition.symbol) |