diff --git a/Lib/fontTools/misc/configTools.py b/Lib/fontTools/misc/configTools.py index dd6c814de..dbbd56ce1 100644 --- a/Lib/fontTools/misc/configTools.py +++ b/Lib/fontTools/misc/configTools.py @@ -110,11 +110,9 @@ class Options(Mapping): """ __options: Dict[str, Option] - __cache: Set[Option] def __init__(self, other: "Options" = None) -> None: self.__options = {} - self.__cache = set() if other is not None: for option in other.values(): self.register_option(option) @@ -135,15 +133,12 @@ class Options(Mapping): name = option.name if name in self.__options: raise ConfigAlreadyRegisteredError(name) - # sanity check option values are unique - assert option not in self.__cache self.__options[name] = option - self.__cache.add(option) return option def is_registered(self, option: Option) -> bool: - """Return True if the option object is already registered.""" - return option in self.__cache + """Return True if the same option object is already registered.""" + return self.__options.get(option.name) is option def __getitem__(self, key: str) -> Option: return self.__options.__getitem__(key)