Permalink
Browse files

Use cap’n proto for bundle index

This makes loading time roughly twice as fast, although some of the speed gain is because we no longer need to convert CFPropertyListRef → plist::any_t.
  • Loading branch information...
sorbits committed Aug 17, 2013
1 parent 4080e1d commit 5c02b4ff5cc0c7c319d3d4f127c8ee19b81f80b7
Showing with 18 additions and 6 deletions.
  1. +2 −2 Applications/gtm/src/gtm.cc
  2. +15 −3 Frameworks/BundlesManager/src/BundlesManager.mm
  3. +1 −1 Frameworks/plist/target
@@ -102,10 +102,10 @@ static void load_bundle_index (bool verbose)
{
oak::duration_t timer;
std::string const path = path::join(path::home(), "Library/Caches/com.macromates.TextMate/BundlesIndex.plist");
std::string const path = path::join(path::home(), "Library/Caches/com.macromates.TextMate/BundlesIndex.binary");
plist::cache_t cache;
cache.load(path);
cache.load_capnp(path);
std::vector<std::string> paths;
for(auto path : bundles::locations())
@@ -337,7 +337,7 @@ - (void)saveBundlesIndex:(id)sender
cache.cleanup(bundlesPaths);
if(cache.dirty())
{
cache.save(bundlesIndexPath);
cache.save_capnp(bundlesIndexPath);
cache.set_dirty(false);
}
_needsSaveBundlesIndex = NO;
@@ -479,9 +479,21 @@ - (void)loadBundlesIndex
{
for(auto path : bundles::locations())
bundlesPaths.push_back(path::join(path, "Bundles"));
bundlesIndexPath = path::join(path::home(), "Library/Caches/com.macromates.TextMate/BundlesIndex.plist");
bundlesIndexPath = path::join(path::home(), "Library/Caches/com.macromates.TextMate/BundlesIndex.binary");
cache.set_content_filter(&prune_dictionary);
cache.load(bundlesIndexPath);
std::string const oldPath = path::join(path::home(), "Library/Caches/com.macromates.TextMate/BundlesIndex.plist");
if(access(oldPath.c_str(), R_OK) == 0)
{
cache.load(oldPath);
cache.save_capnp(bundlesIndexPath);
unlink(oldPath.c_str());
}
else
{
cache.load_capnp(bundlesIndexPath);
}
_needsCreateBundlesIndex = YES;
[self createBundlesIndex:self];
}
@@ -1,7 +1,7 @@
SOURCES = src/*.{cc,rl,capnp}
TESTS = tests/*.cc
LINK += text cf io
LN_FLAGS += /usr/local/lib/libcapnp.a
LIBS += capnp
FRAMEWORKS = CoreFoundation
EXPORT = src/*.h

0 comments on commit 5c02b4f

Please sign in to comment.