Further reduction of CFURL creation and caching of method values.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I
2010-03-06 16:53:24 -08:00
parent d3ba51104e
commit 50ff20ba33
4 changed files with 23 additions and 12 deletions
+3
View File
@@ -110,6 +110,9 @@ if (typeof OBJJ_AUTO_BOOTSTRAP === "undefined" || OBJJ_AUTO_BOOTSTRAP)
function makeAbsoluteURL(/*CFURL|String*/ aURL)
{
if (aURL instanceof CFURL && aURL.scheme())
return aURL;
return new CFURL(aURL, mainBundleURL);
}
-1
View File
@@ -3,6 +3,5 @@ var ObjectiveJ = { };
(function (global, exports)
{
var global = (function() { return this; })();
#include "Includes.js"
})(window, ObjectiveJ);
+6 -6
View File
@@ -46,7 +46,7 @@ GLOBAL(CFBundle) = function(/*CFURL|String*/ aURL)
CFBundlesForURLStrings[URLString] = this;
this._bundleURL = aURL;
this._resourcesDirectoryURL = CFURL("Resources/", aURL);
this._resourcesDirectoryURL = new CFURL("Resources/", aURL);
this._staticResource = NULL;
@@ -66,7 +66,7 @@ CFBundle.environments = function()
CFBundle.bundleContainingURL = function(/*CFURL|String*/ aURL)
{
aURL = CFURL(".", makeAbsoluteURL(aURL));
aURL = new CFURL(".", makeAbsoluteURL(aURL));
while (aURL.path() !== "/")
{
@@ -75,7 +75,7 @@ CFBundle.bundleContainingURL = function(/*CFURL|String*/ aURL)
if (bundle)
return bundle;
aURL = CFURL("..", aURL);
aURL = new CFURL("..", aURL);
}
return NULL;
@@ -115,7 +115,7 @@ CFBundle.prototype.resourceURL = function(/*String*/ aResourceName, /*String*/ a
if (aSubDirectory)
aResourceName = aSubDirectory + "/" + aResourceName;
var resourceURL = CFURL(aResourceName, this.resourcesDirectoryURL()).mappedURL();
var resourceURL = (new CFURL(aResourceName, this.resourcesDirectoryURL())).mappedURL();
return resourceURL.absoluteURL();
}
@@ -123,7 +123,7 @@ CFBundle.prototype.resourceURL = function(/*String*/ aResourceName, /*String*/ a
CFBundle.prototype.mostEligibleEnvironmentURL = function()
{
if (this._mostEligibleEnvironmentURL === undefined)
this._mostEligibleEnvironmentURL = CFURL(this.mostEligibleEnvironment() + ".environment/", this.bundleURL());
this._mostEligibleEnvironmentURL = new CFURL(this.mostEligibleEnvironment() + ".environment/", this.bundleURL());
return this._mostEligibleEnvironmentURL;
}
@@ -137,7 +137,7 @@ CFBundle.prototype.executableURL = function()
if (!executableSubPath)
this._executableURL = NULL;
else
this._executableURL = CFURL(executableSubPath, this.mostEligibleEnvironmentURL());
this._executableURL = new CFURL(executableSubPath, this.mostEligibleEnvironmentURL());
}
return this._executableURL;
+14 -5
View File
@@ -537,14 +537,23 @@ CFURL.prototype.queryString = function()
CFURL.prototype.scheme = function()
{
var scheme = PARTS(this).scheme;
var scheme = this._scheme;
if (scheme)
return scheme;
if (scheme === undefined)
{
scheme = PARTS(this).scheme;
var baseURL = this.baseURL();
if (!scheme)
{
var baseURL = this.baseURL();
return baseURL && baseURL.scheme();
scheme = baseURL && baseURL.scheme();
}
this._scheme = scheme;
}
return scheme;
}
CFURL.prototype.user = function()