]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
Use sets to calculate added/original/removed ips
authorPavel Bondar <pbondar@infoblox.com>
Thu, 11 Jun 2015 12:04:48 +0000 (15:04 +0300)
committerPavel Bondar <pbondar@infoblox.com>
Tue, 23 Jun 2015 08:35:12 +0000 (11:35 +0300)
commitaaa070868e8fb891e6ab5f8355bb03ee3e837c9e
tree36fd0a53fbc01d1fb2355ea5a78f513500b4196e
parent364e7bb4f0fbbf9d11bfb727ccabc40cc48ad9b7
Use sets to calculate added/original/removed ips

Original algorithm to calculate added/removed ips had O(n^2) complexity.
Using sets achieves O(n) for average case.
After refactoring input is no longer affected,
updated tests to reflect that.
However, dataset is too small to get any significant performance
improvement.

Using sets requires additional preparation and post operations:
- converting 'original_ips' and 'new_ips' to sets from ip_addresses
- building map(dict) for storing reference from ip_address to 'ips'
  element
- converting calculated add/orignal/remove sets back to list of dicts
  using map (dict of references).

Partially-Implements: blueprint neutron-ipam

Change-Id: Iecddc406f7b91cfdfb976882504113734e19b565
neutron/db/ipam_backend_mixin.py
neutron/tests/unit/db/test_ipam_backend_mixin.py