Переглянути джерело

[lua] minor map speed tweak, adjust loop spacing

Justin Donaldson 8 роки тому
батько
коміт
5488de810e

+ 2 - 0
src/generators/genlua.ml

@@ -476,6 +476,7 @@ and gen_loop ctx label cond e =
     if will_continue then begin
         println ctx "local _hx_continue_%i = false;" ctx.break_depth;
     end;
+    let b = open_block ctx in
     print ctx "%s " label;
     gen_cond ctx cond;
     print ctx " do ";
@@ -494,6 +495,7 @@ and gen_loop ctx label cond e =
             println ctx "break;";
         println ctx "end;";
     end;
+    b();
     print ctx "end";
     ctx.in_loop <- old_in_loop;
     ctx.break_depth <- ctx.break_depth-1;

+ 4 - 5
std/lua/_std/haxe/ds/IntMap.hx

@@ -42,10 +42,9 @@ class IntMap<T> implements haxe.Constraints.IMap<Int,T> {
 	public inline function get( key : Int ) : Null<T> {
 		var ret = h[key];
 		if (ret == tnull){
-			return null;
-		} else {
-			return ret;
+			ret = null;
 		}
+		return ret;
 	}
 
 	public inline function exists( key : Int ) : Bool {
@@ -69,7 +68,7 @@ class IntMap<T> implements haxe.Constraints.IMap<Int,T> {
 				cur = Lua.next(h,cur).index;
 				return cast ret;
 			},
-			hasNext : function() return cur != null 
+			hasNext : function() return cur != null
 		}
 	}
 
@@ -80,7 +79,7 @@ class IntMap<T> implements haxe.Constraints.IMap<Int,T> {
 			next : function() return h[it.next()]
 		};
 	}
-	
+
 	public function copy() : IntMap<T> {
 		var copied = new IntMap();
 		for(key in keys()) copied.set(key, get(key));

+ 2 - 3
std/lua/_std/haxe/ds/StringMap.hx

@@ -42,10 +42,9 @@ class StringMap<T> implements haxe.Constraints.IMap<String,T> {
 	public inline function get( key : String ) : Null<T> untyped {
 		var ret = h[key];
 		if (ret == tnull){
-			return null;
-		} else {
-			return ret;
+			ret = null;
 		}
+		return ret;
 	}
 
 	public inline function exists( key : String ) : Bool untyped {