From 50ff20ba331a55627719ff5fa1f7b15ef28ec2d9 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Sat, 6 Mar 2010 16:53:24 -0800 Subject: [PATCH] Further reduction of CFURL creation and caching of method values. Reviewed by me. --- Objective-J/Bootstrap.js | 3 +++ Objective-J/Browser/Objective-J.js | 1 - Objective-J/CFBundle.js | 12 ++++++------ Objective-J/CFURL.js | 19 ++++++++++++++----- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Objective-J/Bootstrap.js b/Objective-J/Bootstrap.js index ddc6f6bc9..7f5dbb203 100644 --- a/Objective-J/Bootstrap.js +++ b/Objective-J/Bootstrap.js @@ -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); } diff --git a/Objective-J/Browser/Objective-J.js b/Objective-J/Browser/Objective-J.js index 1727a9713..529013745 100644 --- a/Objective-J/Browser/Objective-J.js +++ b/Objective-J/Browser/Objective-J.js @@ -3,6 +3,5 @@ var ObjectiveJ = { }; (function (global, exports) { - var global = (function() { return this; })(); #include "Includes.js" })(window, ObjectiveJ); diff --git a/Objective-J/CFBundle.js b/Objective-J/CFBundle.js index e0dd3c72c..cae1aeb2a 100644 --- a/Objective-J/CFBundle.js +++ b/Objective-J/CFBundle.js @@ -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; diff --git a/Objective-J/CFURL.js b/Objective-J/CFURL.js index 55f9e69dc..a90c20dce 100644 --- a/Objective-J/CFURL.js +++ b/Objective-J/CFURL.js @@ -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()