Skip to content
This repository was archived by the owner on Jun 16, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 11 additions & 20 deletions src/codeweaver/semantic/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,33 +344,24 @@ def _get_direct_connections_by_source(
"""Get DirectConnections by their source Thing name across all languages."""
if language:
yield from self.direct_connections[language].get(source, [])
yield from (
next(
(
conns
for content in self._direct_connections.values()
for con_name, conns in content.items()
if con_name == source
),
[],
)
)
# Iterate over contents using direct key lookups to avoid O(N^2) generator overhead and preserve O(1) hash map access
else:
for content in self._direct_connections.values():
if source in content:
yield from content[source]
break
Comment on lines +349 to +352

def _get_positional_connections_by_source(
self, source: ThingNameT, *, language: SemanticSearchLanguage | None = None
) -> PositionalConnections | None:
"""Get PositionalConnectionss by their source Thing name across all languages."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (typo): Fix minor typo in the positional connections docstring.

The docstring currently says PositionalConnectionss (double s); please update to PositionalConnections to keep the name consistent with the type.

Suggested change
"""Get PositionalConnectionss by their source Thing name across all languages."""
"""Get PositionalConnections by their source Thing name across all languages."""

if language:
return self.positional_connections[language].get(source)
return next(
(
conn
for content in self._positional_connections.values()
for con_name, conn in content.items()
if con_name == source
),
None,
)
# Iterate over contents using direct key lookups to avoid O(N^2) generator overhead and preserve O(1) hash map access
for content in self._positional_connections.values():
Comment on lines 357 to +361
if source in content:
return content[source]
return None

def get_positional_connections_by_source(
self, source: ThingNameT, *, language: SemanticSearchLanguage | None = None
Expand Down
Loading