Skip to content

Commit

Permalink
Modified executable loader to be much more efficient than just callin…
Browse files Browse the repository at this point in the history
…g objj_import recursively.

Reviewed by me.
  • Loading branch information
Francisco Ryan Tolmasky I committed Jan 20, 2009
1 parent b371a73 commit 1ef0e1c
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions Foundation/CPBundle.j
Expand Up @@ -123,17 +123,18 @@
{
objj_decompile([data string], self);

var files = [self objectForInfoDictionaryKey:@"CPBundleReplacedFiles"];
importCallback = function()
{
// FIXME: Should we share a common context across all these loads?
if (files.length > 0)
objj_import([self bundlePath] + '/' + files.pop(), YES, importCallback);
else if ([_delegate respondsToSelector:@selector(bundleDidFinishLoading:)])
[_delegate bundleDidFinishLoading:self];
}
var context = new objj_context();

if ([_delegate respondsToSelector:@selector(bundleDidFinishLoading:)])
context.didCompleteCallback = function() { [_delegate bundleDidFinishLoading:self]; };

var files = [self objectForInfoDictionaryKey:@"CPBundleReplacedFiles"],
count = files.length;

while (count--)
context.pushFragment(fragment_create_file([self bundlePath] + '/' + files[count], new objj_bundle(""), YES, NULL));

objj_import([self bundlePath] + '/' + files.pop(), YES, importCallback);
context.evaluate();
}
}

Expand Down

0 comments on commit 1ef0e1c

Please sign in to comment.