Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Unified Diff: client/dom/scripts/database.py

Issue 9403004: Wrapperless dart:html generator (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Cleanup Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: client/dom/scripts/database.py
diff --git a/client/dom/scripts/database.py b/client/dom/scripts/database.py
index 225f5984f056b71251a614d902126e736e0ae74b..661f868527fb47aec4e4f007798d614970639956 100755
--- a/client/dom/scripts/database.py
+++ b/client/dom/scripts/database.py
@@ -6,6 +6,7 @@
"""Module to manage IDL files."""
import copy
+import pickle
import logging
import os
import os.path
@@ -119,6 +120,21 @@ class Database(object):
# FIXME: Speed this up by multi-threading.
for (interface_name) in self._ScanForInterfaces():
self._LoadInterfaceFile(interface_name)
+ self.Cache()
+
+ def Cache(self):
sra1 2012/02/16 04:43:28 nit: Cache is both a noun and a verb. Maybe SaveT
+ """Serialize the database using pickle for faster startup in the future
+ """
+ output_file = open('../database/cache.pickle', 'wb')
+ pickle.dump(self._all_interfaces, output_file)
+ pickle.dump(self._interfaces_to_delete, output_file)
+
+ def LoadFromCache(self):
+ """Deserialize the database using pickle for fast startup
+ """
+ input_file = open('../database/cache.pickle', 'rb')
+ self._all_interfaces = pickle.load(input_file)
+ self._interfaces_to_delete = pickle.load(input_file)
def Save(self):
"""Saves all in-memory interfaces into files."""

Powered by Google App Engine
This is Rietveld 408576698