Skip to content

Commit

Permalink
avoid using RulesRegistry.search() since it's slow
Browse files Browse the repository at this point in the history
  • Loading branch information
BurnzZ committed Jan 10, 2023
1 parent 7bd6783 commit 3c6fdae
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scrapy_poet/page_input_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ def provided_classes(self, cls):
"""If the item is in any of the ``to_return`` in the rules, then it can
definitely provide by using the corresponding page object in ``use``.
"""
return isclass(cls) and self.registry.search(to_return=cls)
# avoid using ``web_poet.RulesRegistry.search()`` since it's O(N)
return isclass(cls) and self.registry._item_matchers.get(cls)

def update_cache(self, request: Request, mapping: Dict[Type, Any]) -> None:
if request not in self._cached_instances:
Expand Down

0 comments on commit 3c6fdae

Please sign in to comment.