Permalink
Browse files

#52 dictionary member check performance improved.

  • Loading branch information...
MindScriptAct committed Nov 29, 2013
1 parent bd80221 commit 1dd97eec871aa4db7872c14de5e731ac8abbab1e
@@ -89,7 +89,7 @@ public class CommandMap {
}
}
- if (classRegistry[type]) {
+ if (type in classRegistry) {
if (!canMapOver) {
throw Error("Only one command class can be mapped to one message type. You are trying to map " + commandClass + " to " + type + ", but it is already mapped to " + classRegistry[type]);
}
@@ -212,7 +212,7 @@ public class CommandMap {
* @return true if command pool is created.
*/
public function isCommandPooled(commandClass:Class):Boolean {
- return (commandPools[commandClass] != null && commandPools[commandClass].length);
+ return (commandClass in commandPools && commandPools[commandClass].length);
}
/**
@@ -241,7 +241,7 @@ public class CommandMap {
*/
public function isMapped(type:String, commandClass:Class = null):Boolean {
var retVal:Boolean; // = false;
- if (classRegistry[type]) {
+ if (type in classRegistry) {
if (commandClass) {
retVal = (classRegistry[type] == commandClass);
} else {
@@ -402,13 +402,13 @@ public class CommandMap {
pureLegsCore function validateCommandClass(commandClass:Class):void {
// skip already validated classes.
- if (validatedCommands[commandClass] != true) {
+ if (!(commandClass in validatedCommands)) {
if (!checkClassSuperclass(commandClass, "mvcexpress.mvc::Command")) {
throw Error("commandClass:" + commandClass + " you are trying to map MUST extend: 'mvcexpress.mvc::Command' class.");
}
- if (!commandClassParamTypes[commandClass]) {
+ if (!(commandClass in commandClassParamTypes)) {
var classDescription:XML = describeType(commandClass);
var hasExecute:Boolean; // = false;
@@ -35,7 +35,7 @@ public class ExtensionManager {
*/
CONFIG::debug
public static function getExtensionIdByName(extensionName:String):int {
- if (ExtensionManager.EXTENSION_NAMES[extensionName] == null) {
+ if (!(extensionName in ExtensionManager.EXTENSION_NAMES)) {
ExtensionManager.EXTENSION_NAMES[extensionName] = ++ExtensionManager.extensionCount;
}
return ExtensionManager.EXTENSION_NAMES[extensionName];
@@ -68,7 +68,7 @@ public class ExtensionManager {
use namespace pureLegsCore;
var retVal:int = 0;
- if (!extensionIdRegistry[frameworkClass]) {
+ if (!(frameworkClass in extensionIdRegistry)) {
var currentClass:Class = frameworkClass;
while (retVal == 0 && currentClass != Object) {
retVal = currentClass["extension_id"];
@@ -86,17 +86,17 @@ public class MediatorMap implements IMediatorMap {
}
// check if mapping is not created already
- if (mediatorMappingRegistry[viewClass] != null) {
- if (mediatorMappingRegistry[viewClass][mediatorClass] != null) {
+ if ((viewClass in mediatorMappingRegistry)) {
+ if (mediatorClass in mediatorMappingRegistry[viewClass]) {
throw Error("Mediator class:" + mediatorClass + " is already mapped with this view class:" + viewClass + "");
}
}
// map mediatorClass to viewClass
- if (mediatorMappingRegistry[viewClass] == null) {
+ if (!(viewClass in mediatorMappingRegistry)) {
mediatorMappingRegistry[viewClass] = new Dictionary();
}
- if (mediatorMapOrderRegistry[viewClass] == null) {
+ if (!(viewClass in mediatorMapOrderRegistry)) {
mediatorMapOrderRegistry[viewClass] = new Vector.<Class>();
}
@@ -137,7 +137,7 @@ public class MediatorMap implements IMediatorMap {
MvcExpress.debug(new TraceMediatorMap_unmap(moduleName, viewClass, mediatorClass));
}
// clear mapping
- if (mediatorMappingRegistry[viewClass] != null) {
+ if (viewClass in mediatorMappingRegistry) {
if (mediatorClass) {
var mediators:Vector.<Class> = mediatorMapOrderRegistry[viewClass];
@@ -175,7 +175,7 @@ public class MediatorMap implements IMediatorMap {
public function mediate(viewObject:Object):void {
use namespace pureLegsCore;
- if (mediatorRegistry[viewObject]) {
+ if (viewObject in mediatorRegistry) {
throw Error("This view object is already mediated by " + mediatorRegistry[viewObject]);
}
@@ -241,7 +241,7 @@ public class MediatorMap implements IMediatorMap {
retVal = proxyMap.injectStuff(mediator, mediatorClass, viewObject, injectClass);
- if (mediatorRegistry[viewObject] == null) {
+ if (!(viewObject in mediatorRegistry)) {
mediatorRegistry[viewObject] = new Vector.<Mediator>;
}
mediatorRegistry[viewObject].push(mediator);
@@ -261,7 +261,7 @@ public class MediatorMap implements IMediatorMap {
public function mediateWith(viewObject:Object, mediatorClass:Class, injectClass:Class = null):void {
use namespace pureLegsCore;
- if (mediatorRegistry[viewObject]) {
+ if (viewObject in mediatorRegistry) {
var mediators:Vector.<Mediator> = mediatorRegistry[viewObject];
for (var i:int = 0; i < mediators.length; i++) {
if ((mediators[i] as Object).constructor == mediatorClass) {
@@ -365,7 +365,7 @@ public class MediatorMap implements IMediatorMap {
*/
public function isMapped(viewClass:Class, mediatorClass:Class = null):Boolean {
var retVal:Boolean; // = false;
- if (mediatorMappingRegistry[viewClass] != null) {
+ if (viewClass in mediatorMappingRegistry) {
if (mediatorClass) {
if (mediatorMappingRegistry[viewClass][mediatorClass] != null) {
retVal = true;
@@ -68,7 +68,7 @@ public class ModuleManager {
MvcExpress.debug(new TraceModuleManager_createModule(moduleName));
}
- if (moduleRegistry[moduleName] == null) {
+ if (!(moduleName in moduleRegistry)) {
_moduleId++;
//
if (!moduleName) {
@@ -144,7 +144,7 @@ public class ModuleManager {
CONFIG::debug {
MvcExpress.debug(new TraceModuleManager_disposeModule(moduleName));
}
- if (moduleRegistry[moduleName]) {
+ if (moduleName in moduleRegistry) {
delete moduleRegistry[moduleName];
} else {
throw Error("Module with moduleName:" + moduleName + " doesn't exist.");
@@ -186,7 +186,7 @@ public class ModuleManager {
* @return
*/
static public function listMappedMessages(moduleName:String):String {
- if (moduleRegistry[moduleName]) {
+ if (moduleName in moduleRegistry) {
return (moduleRegistry[moduleName] as ModuleCore).listMappedMessages();
} else {
return "Module with name :" + moduleName + " is not found.";
@@ -199,7 +199,7 @@ public class ModuleManager {
* @return
*/
static public function listMappedMediators(moduleName:String):String {
- if (moduleRegistry[moduleName]) {
+ if (moduleName in moduleRegistry) {
return (moduleRegistry[moduleName] as ModuleCore).listMappedMediators();
} else {
return "Module with name :" + moduleName + " is not found.";
@@ -212,7 +212,7 @@ public class ModuleManager {
* @return
*/
static public function listMappedProxies(moduleName:String):String {
- if (moduleRegistry[moduleName]) {
+ if (moduleName in moduleRegistry) {
return (moduleRegistry[moduleName] as ModuleCore).listMappedProxies();
} else {
return "Module with name :" + moduleName + " is not found.";
@@ -225,7 +225,7 @@ public class ModuleManager {
* @return
*/
static public function listMappedCommands(moduleName:String):String {
- if (moduleRegistry[moduleName]) {
+ if (moduleName in moduleRegistry) {
return (moduleRegistry[moduleName] as ModuleCore).listMappedCommands();
} else {
return "Module with name :" + moduleName + " is not found.";
@@ -244,7 +244,7 @@ public class ModuleManager {
* @private
*/
static pureLegsCore function invokeModuleFunction(moduleName:String, functionName:String, params:Array = null):Object {
- if (moduleRegistry[moduleName]) {
+ if (moduleName in moduleRegistry) {
try {
var callFunct:Function = moduleRegistry[moduleName][functionName]
if (params) {
Oops, something went wrong.

0 comments on commit 1dd97ee

Please sign in to comment.