Skip to content

Commit

Permalink
Merge pull request #200 from kytos-ng/enhacement/link
Browse files Browse the repository at this point in the history
Optimized `_get_link_or_create`
  • Loading branch information
viniarck authored May 21, 2024
2 parents 968845c + 8c6195b commit 695b3b5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ def _get_link_or_create(self, endpoint_a, endpoint_b):
"""
new_link = Link(endpoint_a, endpoint_b)

for link in self.links.values():
if new_link == link:
return (link, False)
if new_link.id in self.links:
return (self.links[new_link.id], False)

self.links[new_link.id] = new_link
return (new_link, True)
Expand Down

0 comments on commit 695b3b5

Please sign in to comment.