Convert pin map to a set for faster membership.

This commit is contained in:
Matt Guthaus 2019-04-01 15:45:44 -07:00
parent 74f904a509
commit 5f37677225
2 changed files with 8 additions and 9 deletions

View File

@ -190,7 +190,8 @@ class layout():
debug.error("Should use a pin iterator since more than one pin {}".format(text),-1) debug.error("Should use a pin iterator since more than one pin {}".format(text),-1)
# If we have one pin, return it and not the list. # If we have one pin, return it and not the list.
# Otherwise, should use get_pins() # Otherwise, should use get_pins()
return self.pin_map[text][0] any_pin = next(iter(self.pin_map[text]))
return any_pin
except Exception as e: except Exception as e:
#print e #print e
self.gds_write("missing_pin.gds") self.gds_write("missing_pin.gds")
@ -260,7 +261,7 @@ class layout():
""" """
Delete a labeled pin (or all pins of the same name) Delete a labeled pin (or all pins of the same name)
""" """
self.pin_map[text]=[] self.pin_map[text]=set()
def add_layout_pin(self, text, layer, offset, width=None, height=None): def add_layout_pin(self, text, layer, offset, width=None, height=None):
""" """
@ -277,13 +278,11 @@ class layout():
# Check if there's a duplicate! # Check if there's a duplicate!
# and if so, silently ignore it. # and if so, silently ignore it.
# Rounding errors may result in some duplicates. # Rounding errors may result in some duplicates.
pin_list = self.pin_map[text] if new_pin not in self.pin_map[text]:
for pin in pin_list: self.pin_map[text].add(new_pin)
if pin == new_pin:
return pin
self.pin_map[text].append(new_pin)
except KeyError: except KeyError:
self.pin_map[text] = [new_pin] self.pin_map[text] = set()
self.pin_map[text].add(new_pin)
return new_pin return new_pin

View File

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
python3 -m cProfile -o profile.dat ./openram.py example_configs/medium_config_scn4m_subm.py -v | tee -i medium.log python3 -m cProfile -o profile.dat ./openram.py example_configs/giant_config_scn4m_subm.py -v | tee -i big.log
echo "Run view_profile.py to view results" echo "Run view_profile.py to view results"