Skip to content

Commit

Permalink
Use iteritems to save memory
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcutme committed Apr 25, 2016
1 parent 038bf4f commit bf38492
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Site/SiteStorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def rebuildDb(self, delete_db=True):
cur.logging = False
found = 0
s = time.time()
for content_inner_path, content in self.site.content_manager.contents.items():
for content_inner_path, content in self.site.content_manager.contents.iteritems():
content_path = self.getPath(content_inner_path)
if os.path.isfile(content_path): # Missing content.json file
if self.db.loadJson(content_path, cur=cur):
Expand Down Expand Up @@ -283,7 +283,7 @@ def verifyFiles(self, quick_check=False, add_optional=False, add_changed=True):
if not self.site.content_manager.contents.get("content.json"): # No content.json, download it first
self.site.needFile("content.json", update=True) # Force update to fix corrupt file
self.site.content_manager.loadContent() # Reload content.json
for content_inner_path, content in self.site.content_manager.contents.items():
for content_inner_path, content in self.site.content_manager.contents.iteritems():
i += 1
if i % 50 == 0:
time.sleep(0.0001) # Context switch to avoid gevent hangs
Expand Down Expand Up @@ -376,7 +376,7 @@ def deleteFiles(self):

self.log.debug("Deleting files from content.json...")
files = [] # Get filenames
for content_inner_path, content in self.site.content_manager.contents.items():
for content_inner_path, content in self.site.content_manager.contents.iteritems():
files.append(content_inner_path)
# Add normal files
for file_relative_path in content.get("files", {}).keys():
Expand Down

0 comments on commit bf38492

Please sign in to comment.