[Swift-commit] Cog update

swift at ci.uchicago.edu swift at ci.uchicago.edu
Thu May 3 12:10:26 CDT 2012


------------------------------------------------------------------------
r3400 | hategan | 2012-04-30 22:51:26 -0500 (Mon, 30 Apr 2012) | 1 line

slightly faster and cleaner variable frame cachin code
------------------------------------------------------------------------
Index: modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Variable.java
===================================================================
--- modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Variable.java	(revision 3399)
+++ modules/karajan/src/org/globus/cog/karajan/workflow/nodes/functions/Variable.java	(working copy)
@@ -40,44 +40,35 @@
 
 	public Object function(VariableStack stack) throws ExecutionException {
 		synchronized (this) {
-			if (name == null) {
-				name = TypeUtil.toString(A_NAME.getStatic(this)).toLowerCase();
-				if (getStaticArguments().size() == 1) {
-					java.util.Map<String, Object> m = Collections.emptyMap();
-					setStaticArguments(m);
+			if (frame == UNINITIALIZED || frame == VariableStack.NO_FRAME) {
+				if (name == null) {
+					name = TypeUtil.toString(A_NAME.getStatic(this)).toLowerCase();
+					if (getStaticArguments().size() == 1) {
+						java.util.Map<String, Object> m = Collections.emptyMap();
+						setStaticArguments(m);
+					}
 				}
-			}
-		}
-
-		switch (frame) {
-			case UNINITIALIZED:
-			case VariableStack.NO_FRAME:
+			
 				if (stack.parentFrame().isDefined("#quoted")) {
 					Object value = new Identifier(name);
 					setSimple(value);
 					return value;
 				}
-				else {
-					frame = stack.getVarFrameFromTop(name);
-					switch (frame) {
-					    case VariableStack.NO_FRAME:
-					        throw new VariableNotFoundException(name);
-					    case VariableStack.FIRST_FRAME:
-					        Object value = stack.firstFrame().getVar(name);
-					        setSimple(value);
-					        return value;
-					    case VariableStack.DYNAMIC_FRAME:
-					        return stack.getVar(name);
-					    default:
-					        return stack.getFrameFromTop(frame).getVar(name);
-					}
-				}
+				frame = stack.getVarFrameFromTop(name);
+			}
+		}
+		
+		switch (frame) {
+			case VariableStack.NO_FRAME:
+				throw new VariableNotFoundException(name);
 			case VariableStack.FIRST_FRAME:
-			    return stack.firstFrame().getVar(name);
+				Object value = stack.firstFrame().getVar(name);
+				setSimple(value);
+				return value;
 			case VariableStack.DYNAMIC_FRAME:
-			    return stack.getVar(name);
+				return stack.getVar(name);
 			default:
-			    return stack.getFrameFromTop(frame).getVar(name);
+				return stack.getFrameFromTop(frame).getVar(name);
 		}
 	}
 }
Index: modules/karajan/src/org/globus/cog/karajan/util/ElementProperty.java
===================================================================
--- modules/karajan/src/org/globus/cog/karajan/util/ElementProperty.java	(revision 3399)
+++ modules/karajan/src/org/globus/cog/karajan/util/ElementProperty.java	(working copy)
@@ -130,24 +130,17 @@
 			this.name = ident.getName();
 		}
 
-		public synchronized Object getValue(VariableStack stack) throws VariableNotFoundException {
+		public Object getValue(VariableStack stack) throws VariableNotFoundException {
+			synchronized(this) {
+				if (frame == UNINITIALIZED || frame == VariableStack.NO_FRAME) {
+					frame = stack.getVarFrameFromTop(name);
+				}
+			}
 			switch (frame) {
-				case UNINITIALIZED:
 				case VariableStack.NO_FRAME:
-					frame = stack.getVarFrameFromTop(name);
-					switch (frame) {
-						case VariableStack.NO_FRAME:
-							throw new VariableNotFoundException(name);
-						case VariableStack.FIRST_FRAME:
-							value = stack.firstFrame().getVar(name);
-							return value;
-						case VariableStack.DYNAMIC_FRAME:
-							return stack.getVar(name);
-						default:
-							return stack.getFrameFromTop(frame).getVar(name);
-					}
+					throw new VariableNotFoundException(name);
 				case VariableStack.FIRST_FRAME:
-					return value;
+					return stack.firstFrame().getVar(name);
 				case VariableStack.DYNAMIC_FRAME:
 					return stack.getVar(name);
 				default:



More information about the Swift-commit mailing list