Further performance improvements and better debug values for CFDictionary and CFMutableDictionary.

Reviewed by me.
This commit is contained in:
Francisco Ryan Tolmasky I committed 2010-03-07 12:49:37 -08:00
1 parent 68ae1af13f
commit 64a401125d
3 files changed
+59 -113

No files matched your search

+3 -3
View File
@@ -426,7 +426,7 @@ var _CPKeyedUnarchiverDecodeObjectAtIndex = function(self, anIndex)
var object = self._objects[anIndex];
if (object)
if (object == self._objects[0])
if (object === self._objects[0])
return nil;
else
return object;
@@ -504,9 +504,9 @@ var _CPKeyedUnarchiverDecodeObjectAtIndex = function(self, anIndex)
{
self._objects[anIndex] = object = plistObject;
if ([object class] == CPStringClass)
if ([object class] === CPStringClass)
{
if (object == _CPKeyedArchiverNullString)
if (object === _CPKeyedArchiverNullString)
{
self._objects[anIndex] = self._objects[0];
+56
View File
@@ -65,6 +65,10 @@ CFDictionary.prototype.containsKey = function(/*String*/ aKey)
return hasOwnProperty.apply(this._buckets, [aKey]);
}
#if DEBUG
CFDictionary.prototype.containsKey.displayName = "CFDictionary.containsKey";
#endif
CFDictionary.prototype.containsValue = function(/*id*/ anObject)
{
var keys = this._keys,
@@ -79,16 +83,31 @@ CFDictionary.prototype.containsValue = function(/*id*/ anObject)
return NO;
}
#if DEBUG
CFDictionary.prototype.containsValue.displayName = "CFDictionary.containsValue";
#endif
CFDictionary.prototype.count = function()
{
return this._count;
}
#if DEBUG
CFDictionary.prototype.count.displayName = "CFDictionary.count";
#endif
CFDictionary.prototype.countOfKey = function(/*String*/ aKey)
{
return this.containsKey(aKey) ? 1 : 0;
}
#if DEBUG
CFDictionary.prototype.countOfKey.displayName = "CFDictionary.countOfKey";
#endif
CFDictionary.prototype.countOfValue = function(/*id*/ anObject)
{
var keys = this._keys,
@@ -104,11 +123,20 @@ CFDictionary.prototype.countOfValue = function(/*id*/ anObject)
return countOfValue;
}
#if DEBUG
CFDictionary.prototype.countOfValue.displayName = "CFDictionary.countOfValue";
#endif
CFDictionary.prototype.keys = function()
{
return this._keys.slice();
}
#if DEBUG
CFDictionary.prototype.keys.displayName = "CFDictionary.keys";
#endif
CFDictionary.prototype.valueForKey = function(/*String*/ aKey)
{
var buckets = this._buckets;
@@ -119,6 +147,10 @@ CFDictionary.prototype.valueForKey = function(/*String*/ aKey)
return buckets[aKey];
}
#if DEBUG
CFDictionary.prototype.valueForKey.displayName = "CFDictionary.valueForKey";
#endif
CFDictionary.prototype.toString = function()
{
var string = "{\n",
@@ -136,6 +168,10 @@ CFDictionary.prototype.toString = function()
return string + "}";
}
#if DEBUG
CFDictionary.prototype.toString.displayName = "CFDictionary.toString";
#endif
GLOBAL(CFMutableDictionary) = function(/*CFDictionary*/ aDictionary)
{
CFDictionary.apply(this, []);
@@ -159,6 +195,10 @@ CFMutableDictionary.prototype.addValueForKey = function(/*String*/ aKey, /*Objec
this._buckets[aKey] = aValue;
}
#if DEBUG
CFMutableDictionary.prototype.addValueForKey.displayName = "CFMutableDictionary.addValueForKey";
#endif
CFMutableDictionary.prototype.removeValueForKey = function(/*String*/ aKey)
{
var indexOfKey = -1;
@@ -188,6 +228,10 @@ CFMutableDictionary.prototype.removeValueForKey = function(/*String*/ aKey)
delete this._buckets[aKey];
}
#if DEBUG
CFMutableDictionary.prototype.removeValueForKey.displayName = "CFMutableDictionary.removeValueForKey";
#endif
CFMutableDictionary.prototype.removeAllValues = function()
{
this._count = 0;
@@ -195,6 +239,10 @@ CFMutableDictionary.prototype.removeAllValues = function()
this._buckets = { };
}
#if DEBUG
CFMutableDictionary.prototype.removeAllValues.displayName = "CFMutableDictionary.removeAllValues";
#endif
CFMutableDictionary.prototype.replaceValueForKey = function(/*String*/ aKey, /*Object*/ aValue)
{
if (!this.containsKey(aKey))
@@ -203,6 +251,10 @@ CFMutableDictionary.prototype.replaceValueForKey = function(/*String*/ aKey, /*O
this._buckets[aKey] = aValue;
}
#if DEBUG
CFMutableDictionary.prototype.replaceValueForKey.displayName = "CFMutableDictionary.replaceValueForKey";
#endif
CFMutableDictionary.prototype.setValueForKey = function(/*String*/ aKey, /*Object*/ aValue)
{
if (aValue === nil || aValue === undefined)
@@ -214,3 +266,7 @@ CFMutableDictionary.prototype.setValueForKey = function(/*String*/ aKey, /*Objec
else
this.addValueForKey(aKey, aValue);
}
#if DEBUG
CFMutableDictionary.prototype.setValueForKey.displayName = "CFMutableDictionary.setValueForKey";
#endif
-110
View File
@@ -1,110 +0,0 @@
/*
* FileExecutableSearch.js
* Objective-J
*
* Created by Francisco Tolmasky.
* Copyright 2010, 280 North, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
var FileExecutableSearchesForPaths = [{ }, { }];
function FileExecutableSearch(/*CFURL*/ aURL, /*BOOL*/ isQuoted)
{
// if (isQuoted && !aURL.protocol())
// throw "Local searches cannot be relative: " + aPath;
var URLString = aURL.absoluteString(),
existingSearch = FileExecutableSearchesForPaths[isQuoted ? 1 : 0][URLString];
if (existingSearch)
return existingSearch;
FileExecutableSearchesForPaths[isQuoted ? 1 : 0][URLString] = this;
this._UID = objj_generateObjectUID();
this._URL = aURL;
this._isComplete = NO;
this._eventDispatcher = new EventDispatcher(this);
this._result = NULL;
var self = this;
function completed(/*String*/ aStaticResource)
{
if (!aStaticResource)
throw new Error("Could not load file at " + aURL);
self._result = new FileExecutable(aStaticResource.URL());
self._isComplete = YES;
self._eventDispatcher.dispatchEvent(
{
type:"complete",
fileExecutableSearch:self
});
}
if (isQuoted)
StaticResource.resolveResourceAtURL(aURL, NO, completed);
else
StaticResource.resolveResourceAtURLSearchingIncludeURLs(aURL, completed);
}
exports.FileExecutableSearch = FileExecutableSearch;
FileExecutableSearch.prototype.URL = function()
{
return this._URL;
}
FileExecutableSearch.prototype.result = function()
{
return this._result;
}
FileExecutableSearch.prototype.UID = function()
{
return this._UID;
}
FileExecutableSearch.prototype.isComplete = function()
{
return this._isComplete;
}
FileExecutableSearch.prototype.result = function()
{
return this._result;
}
FileExecutableSearch.prototype.addEventListener = function(/*String*/ anEventName, /*Function*/ aListener)
{
this._eventDispatcher.addEventListener(anEventName, aListener);
}
FileExecutableSearch.prototype.removeEventListener = function(/*String*/ anEventName, /*Function*/ aListener)
{
this._eventDispatcher.removeEventListener(anEventName, aListener);
}
#if DEPENDENCY_LOGGING
FileExecutableSearch.prototype.toString = function()
{
return "<FileExecutableSearch: " + this.path() + ">";
}
#endif