Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 18, 2013
1 parent 4080e1d commit 5c02b4f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Applications/gtm/src/gtm.cc
Expand Up @@ -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())
Expand Down
18 changes: 15 additions & 3 deletions Frameworks/BundlesManager/src/BundlesManager.mm
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
}
Expand Down
2 changes: 1 addition & 1 deletion Frameworks/plist/target
@@ -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.