Closed EricFedrowisch closed 10 years ago
In world.py, there are many for loops created like this:
for figure in world.figures:
for section in self.currentSections:
if figure.section == section.name:
//do stuff
I feel these for loops probably create unnecessary overhead. I am going to try and use a dictionary that is updated with the section names as keys that will be updated at the same time the sections are loading. Something like this:
for figure in world.figures:
if figure.section in currentSectionsDict:
//do stuff
This is shorter and uses a dictionary lookup in an existing hash table which I think is probably much faster than initializing a for loop to search through the current sections.
Imp'd.
I hope to replace several for loops that search thru a list of section objects, checking the section.name value for each with the creation of a dictionary that has the section names as keys that point to the section instance. This would make for shorter code, simpler code. Possibly marginally faster code.